jamalex / notion-py

Unofficial Python API client for Notion.so
MIT License
4.28k stars 476 forks source link

HTTPError (400) when trying to load a database despite trying proposed solutions #392

Open evesdropper opened 8 months ago

evesdropper commented 8 months ago

Getting the following error when trying to load a database; I saw #385 #389 with similar issues, but this happens to me when trying to use client.get_collection. I noticed the solution pointed out here; however, I still get the same errors.

Traceback (most recent call last):
  File "/home/revise/Documents/code/strava-notion.py", line 74, in <module>
    update_notion()
  File "/home/revise/Documents/code/strava-notion.py", line 66, in update_notion
    notion_client, cv = get_notion_client()
                        ^^^^^^^^^^^^^^^^^^^
  File "/home/revise/Documents/code/strava-notion.py", line 57, in get_notion_client
    cv = client.get_collection(notion_database)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/revise/Documents/code/lib/python3.11/site-packages/notion/client.py", line 185, in get_collection
    coll = self.get_record_data(
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/revise/Documents/code/lib/python3.11/site-packages/notion/client.py", line 162, in get_record_data
    return self._store.get(table, id, force_refresh=force_refresh)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/revise/Documents/code/lib/python3.11/site-packages/notion/store.py", line 186, in get
    self.call_get_record_values(**{table: id})
  File "/home/revise/Documents/code/lib/python3.11/site-packages/notion/store.py", line 254, in call_get_record_values
    results = self._client.post(
              ^^^^^^^^^^^^^^^^^^
  File "/home/revise/Documents/code/lib/python3.11/site-packages/notion/client.py", line 260, in post
    raise HTTPError(
requests.exceptions.HTTPError: Something went wrong. (400)

Are there any other workarounds?

philippkeller commented 8 months ago

I got the same error but I got it working by reducing limits at two places (the solution you linked only had it in one place):

After this I was able to both load the collection and also to add records

philippkeller commented 8 months ago

Ah I found out that the code installed by pip is 2 years old. The newest issues have been fixed in the main branch though. All my issues were solved once I added this to my requirements.txt:

git+https://github.com/jamalex/notion-py.git
evesdropper commented 6 months ago

I've tried this multiple times over the last few months, yet it still yields the same HTTPError. I've added git+https://github.com/jamalex/notion-py.git into my requirements.txt (and a quick inspection of store.py verifies that the installation is indeed the correct one), and I'm still running into this problem.

Maybe automating this project wasn't meant to be :shrug: