Value for set_endpoint when using selfhosted appwrite with docker compose
- 0
- Self Hosted
- Functions
what is the correct import for query on python sdk ?
something like from appwrite.query import Query ?
I believe so, yes
getting a 400 error, so you were 1000% right about set_endpoint being correct and my Querry being wrong, the issue is that it's still wrong x)
my code
for i in collections_id :
collections_id = collections_id[i]
result = databases.list_documents(
database_id="65488cf9e88bc75837bd",
collection_id=collections_id,
queries = {
Query.less_than("date", utc_ytd),
Query.limit(100),
Query.offset(0)
}
)
oh I think I know what's wrong
building
still no luck
code
Double check the format of the date, I don’t remember what format is required exactly, but double check it against whatever format is returned.
Error :
Hello, Errors!
Traceback (most recent call last):
File "/usr/local/server/src/function/runtime-env/lib/python3.9/site-packages/appwrite/client.py", line 114, in call
response.raise_for_status()
File "/usr/local/server/src/function/runtime-env/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/server/src/server.py", line 165, in handler
output = await asyncio.wait_for(execute(context), timeout=safeTimeout)
File "/usr/local/lib/python3.9/asyncio/tasks.py", line 479, in wait_for
return fut.result()
File "/usr/local/server/src/server.py", line 158, in execute
output = userModule.main(context)
File "/usr/local/server/src/function/src/main.py", line 53, in main
result = databases.list_documents(
File "/usr/local/server/src/function/runtime-env/lib/python3.9/site-packages/appwrite/services/databases.py", line 916, in list_documents
return self.client.call('get', api_path, {
File "/usr/local/server/src/function/runtime-env/lib/python3.9/site-packages/appwrite/client.py", line 129, in call
raise AppwriteException(response.json()['message'], response.status_code, response.json().get('type'), response.json())
appwrite.exception.AppwriteException: Server Error
on the app sending log to database (which also use the python sdk)
i've used (and it worked) :
current_date = datetime.now()
current_date = current_date.isoformat()
res = database.create_document("collection_id", i[1], ID.unique(), {"raw_json" : logs[i[0]]["raw_json"], "date" : current_date})
Yeah, I think the create_document()
API is more forgiving than the Queries API
Before changing the Queries you were getting a 400 and now you’re getting a 500? Or the other way around?
400 then 500
the 400 error was :
Hello, Errors!
Traceback (most recent call last):
File "/usr/local/server/src/function/runtime-env/lib/python3.9/site-packages/appwrite/client.py", line 114, in call
response.raise_for_status()
File "/usr/local/server/src/function/runtime-env/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/server/src/server.py", line 165, in handler
output = await asyncio.wait_for(execute(context), timeout=safeTimeout)
File "/usr/local/lib/python3.9/asyncio/tasks.py", line 479, in wait_for
return fut.result()
File "/usr/local/server/src/server.py", line 158, in execute
output = userModule.main(context)
File "/usr/local/server/src/function/src/main.py", line 53, in main
result = databases.list_documents(
File "/usr/local/server/src/function/runtime-env/lib/python3.9/site-packages/appwrite/services/databases.py", line 916, in list_documents
return self.client.call('get', api_path, {
File "/usr/local/server/src/function/runtime-env/lib/python3.9/site-packages/appwrite/client.py", line 129, in call
raise AppwriteException(response.json()['message'], response.status_code, response.json().get('type'), response.json())
appwrite.exception.AppwriteException: Invalid `queries` param: Value must a valid array and Value must be a valid string and at least 1 chars and no longer than 4096 chars
I switched from a dict to an array
Yeah, you can see at the end there Invalid ‘queries’ param
So double check that the date you’re passing in is in exactly the format Appwrite returns the date in
'2023-12-10T20:58:29.506+00:00'
the format is different from the one used in the document_create
Yeah, as I said earlier, document_create()
is fairly forgiving of date input formats. Queries are not.
(i used document_list without the query to know what is the real date format in the db)
create_document use ISO 8601, what is the name of the format used for query ?
Whatever is returned by Appwrite - I don’t remember what the standard is.
Recommended threads
- Need help with createExecution function
Hi, Need some help understanding createExecution. When requesting function execution via createExecution, the function handler arguments are incorrect and rese...
- Realtime with multiple connections
I need the Realtime on multiple Collections for diffrent applicational logic. So my question is: Is there a way to have only 1 Websocket connection or do I need...
- Can't login or deploy functions in Appwr...
Hello, since i updatet to the appwrite cli 6.1.0 i can't login or deploy functions with the cli. When i call the command: "appwrite get account --verbose" i ge...