ramnes / notion-sdk-py

The official Notion API client library, but rewritten in Python! (sync + async)

Home Page:https://ramnes.github.io/notion-sdk-py

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://api.notion.com/v1/databases/897e5a76-ae52-4b48-9fdf-e71f5945d1af/query' when running example

roryk opened this issue · comments

This minimal example from the documentation fails for me:

import os
from notion_client import Client

notion = Client(auth=os.environ["NOTION_TOKEN"])
my_page = notion.databases.query(
    **{
        "database_id": "897e5a76-ae52-4b48-9fdf-e71f5945d1af",
        "filter": {
            "property": "Landmark",
            "text": {
                "contains": "Bridge",
            },
        },
    }
)

Other lookups work, it's specifically this filtering down to get an item using the databases.query endpoint. Do you know what might be happening?

httpx.HTTPStatusError: Client error '400 Bad Request' for url 'https://api.notion.com/v1/databases/897e5a76-ae52-4b48-9fdf-e71f5945d1af/query'
For more information check: https://httpstatuses.com/400

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mnt/disks/rorypatch/babel/foo.py", line 5, in <module>
    my_page = notion.databases.query(
  File "/home/rory/miniconda3/envs/babel/lib/python3.10/site-packages/notion_client/api_endpoints.py", line 132, in query
    return self.parent.request(
  File "/home/rory/miniconda3/envs/babel/lib/python3.10/site-packages/notion_client/client.py", line 192, in request
    return self._parse_response(response)
  File "/home/rory/miniconda3/envs/babel/lib/python3.10/site-packages/notion_client/client.py", line 124, in _parse_response
    raise APIResponseError(response, body["message"], code)
notion_client.errors.APIResponseError: body failed validation. Fix one:
body.filter.or should be defined, instead was `undefined`.
body.filter.and should be defined, instead was `undefined`.
body.filter.title should be defined, instead was `undefined`.
body.filter.rich_text should be defined, instead was `undefined`.
body.filter.number should be defined, instead was `undefined`.
body.filter.checkbox should be defined, instead was `undefined`.
body.filter.select should be defined, instead was `undefined`.
body.filter.multi_select should be defined, instead was `undefined`.
body.filter.date should be defined, instead was `undefined`.
body.filter.people should be defined, instead was `undefined`.
body.filter.files should be defined, instead was `undefined`.
body.filter.url should be defined, instead was `undefined`.
body.filter.email should be defined, instead was `undefined`.
body.filter.phone_number should be defined, instead was `undefined`.
body.filter.relation should be defined, instead was `undefined`.
body.filter.created_by should be defined, instead was `undefined`.
body.filter.created_time should be defined, instead was `undefined`.
body.filter.last_edited_by should be defined, instead was `undefined`.
body.filter.last_edited_time should be defined, instead was `undefined`.
body.filter.formula should be defined, instead was `undefined`.
body.filter.rollup should be defined, instead was `undefined`.

is the full error.

Thanks!!