notion-py icon indicating copy to clipboard operation
notion-py copied to clipboard

Got 400 error attempting to POST to queryCollection

Open yanmendes opened this issue 3 years ago • 2 comments

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": []
  }
}

yanmendes avatar Oct 06 '21 19:10 yanmendes

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.

JustDhan avatar Oct 06 '21 20:10 JustDhan

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

wsykala avatar Oct 06 '21 20:10 wsykala