-
I'm trying to get all databases that are nested on a page. I using the search endpoint for this, because there are limitations for the list database endpoint. Then, i did it this way filtering by the object property, as shown in the notion api documentation. results = notion.search(filter={"object":"database"}).get("results") But it return a error, see: Traceback (most recent call last):
File "/home/wookyz/.virtualenvs/telegram-notion/test.py", line 5, in <module>
results = notion.search(filter={"object":"database"}).get("results")
File "/home/wookyz/.virtualenvs/telegram-notion/lib/python3.9/site-packages/notion_client/api_endpoints.py", line 98, in __call__
return self.parent.request(
File "/home/wookyz/.virtualenvs/telegram-notion/lib/python3.9/site-packages/notion_client/client.py", line 133, in request
return self._parse_response(response)
File "/home/wookyz/.virtualenvs/telegram-notion/lib/python3.9/site-packages/notion_client/client.py", line 93, in _parse_response
raise APIResponseError(error.response, body)
notion_client.errors.APIResponseError: body failed validation: body.filter.property should be defined, instead was `undefined`. I have been looking for an example that shows the use of search endpoint with filter, if anyone can do it, I would be very grateful. I also tried using the curl command and it seems to work perfectly fine. curl -X POST 'https://api.notion.com/v1/search' \
-H 'Authorization: Bearer '"$NOTION_API_KEY"''
-H 'Content-Type: application/json' \
-H "Notion-Version: 2021-05-13" \
--data '{
"filter": {"object": "database"}
}' Thank you for the answers!d |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Your cURL command looks weird. I've rewritten it myself and I get the exact same error: $ curl -X POST "https://api.notion.com/v1/search" -H "Authorization: Bearer ${NOTION_TOKEN}" -H "Notion-Version: 2021-05-13" -H "Content-Type: application/json" --data '{"filter": {"object": "database"}}'
{"object":"error","status":400,"code":"validation_error","message":"body failed validation: body.filter.property should be defined, instead was `undefined`."} As per Notion's documentation, here is the filter you should use: {"property": "object", "value": "database"} And it works, with cURL or Python: notion.search(filter={"property": "object", "value": "database"}) I'm not sure how you ended up with two different results. :) |
Beta Was this translation helpful? Give feedback.
Your cURL command looks weird. I've rewritten it myself and I get the exact same error:
As per Notion's documentation, here is the filter you should use:
And it works, with cURL or Python:
I'm not sure how you ended up with…