jamalex / notion-py

Unofficial Python API client for Notion.so
MIT License
4.3k stars 475 forks source link

Got 400 error attempting to POST to queryCollection #350

Open yanmendes opened 3 years ago

yanmendes commented 3 years ago

Hi, I have a script that has been running for a while now and it stopped working yesterday evening.

Here's the call: notionClient.get_collection_view("{databaseURL}").collection.get_rows()

Here's the result:

ERROR:notion:Got 400 error attempting to POST to queryCollection, with data: {
  "collectionId": "collection-id",
  "collectionViewId": "view-id",
  "loader": {
    "limit": 100,
    "loadContentCover": true,
    "searchQuery": "",
    "userLocale": "en",
    "userTimeZone": "America/Fortaleza",
    "type": "table"
  },
  "query": {
    "aggregate": [],
    "aggregations": [],
    "filter": [],
    "sort": []
  }
}
JustDhan commented 3 years ago

Same here. Yesterday all work fine, from this morning i got HTTPError on call_query_collection

Traceback (most recent call last): File "/home/test1.py", line 24, in if get_mode_from_notion() == "V": File "/home/test.py", line 1128, in get_mode_from_notion value = cv.build_query(filter=NotionQueryChekboxIs("true")).execute() File "/home/notion/collection.py", line 385, in execute self._client.query_collection( File "/home/notion/client.py", line 294, in query_collection return self._store.call_query_collection(*args, **kwargs) File "/home/notion/store.py", line 344, in call_query_collection response = self._client.post("queryCollection", data).json() File "/home/", line 260, in post raise HTTPError( requests.exceptions.HTTPError: Invalid input.

wsykala commented 3 years ago

Looks like the request payload has changed for the POST request to queryCollection endpoint and instead of:

"collectionId": "collection-id",
"collectionViewId": "view-id",

it now requires

"collectionId": {
    "id":"collection-id",
    "spaceId":"space-id"
},
"collectionViewId": {
    "id":"view-id",
    "spaceId":"space-id"
},

I will check if my assumptions are correct and will do a pull request