
You need to use this: https://appwrite.io/docs/server/databases?sdk=python-default#databasesListDocuments

i am inserting into a collection the session id and a time i wish for it to be deleted by the cloud function. It is so because i have a remember me checkbox on my ui. So i do need to create an api key

it depends on the permissions on the collection and document

ok for now i put any on create and delete

@Steven i noticed i was missing some params but for now here is the error i get after fixing An error occurred: HTTPConnectionPool(host='127.0.0.1', port=80): Max retries exceeded with url: /v1/databases/64a671fb266768330926/collections/64cbca90100c2734a432/documents (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff84d91a90>: Failed to establish a new connection: [Errno 111] Connection refused'))

i guess since the function are inside a container they cant point to the hoost localhost , ill try my ip

@Steven does appwrite cloud functions support env variables ? if so how can i refer to them in code ?

Did you read the docs on functions?

@Steven Not entirely no let me get back to it then

Short answer is we have function variables rather than environment variables in the current version of functions

@Steven ok let me comb the docs for it

@Steven i managed to run it and now i am stuck with a permission error An error occurred: app.649338b1262c3cbe564c@service.192.168.1.6 (role: applications) missing scope (account)
i gave all scope to my api key though

i think this snippet is the culprit # Delete the session
account = Account(client)
delete_response = account.delete_session(session_id)
print(delete_response)

You should be using the users API

@Steven with a JWT, will it work since ther is no user connected to trigger this function ? it is supposed to run with CRON automatically

If a user isn't triggering the function, you won't have a JWT token 🧐

@Steven indeed so how do i do the session deleting then ? i though i had to set up an API KEY for such a maintenance use case

Use the users API

@Steven sorry ...i confused both as Accounts ...

@Steven Let me revert as soon as i come back

@Steven It is all good now i fixed it thanks to your guidance.

[SOLVED] Python cloud function failing with Internal runtime error

is it possible to return json data in the "message" field ?

yes. if you still need help, please create a new <#1072905050399191082> post.

ok thanks
Recommended threads
- Creating Push Notification Results in Fa...
When creating a push notification using the Python API, I get this error for the status of my message. I call it using basically this: ```python def main(conte...
- Functions in Golang - I need help
Hi guys! I am struggling to deploy a rather simple golang function. The deployment log details are very sparse: "failed error code: 524 " or: "Cannot access ...
- Issue creating team membership with USER...
Log time ago it worked without any issue when I made a demo app but now it is not working in cloud function. code ```await awTeams ?.createMembe...
