jamalex / notion-py

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

requests.exceptions.HTTPError when calling cv.collection.get_rows() #365

Open felipehlvo opened 2 years ago

felipehlvo commented 2 years ago

I get an requests.exceptions.HTTPError after using cv.collection.get_rows()

The full error message is: File "C:\Users\rober\Anaconda3\lib\site-packages\notion\collection.py", line 239, in get_rows return self.query(kwargs) File "C:\Users\rober\Anaconda3\lib\site-packages\notion\collection.py", line 236, in query return CollectionQuery(self, self._get_a_collection_view(), kwargs).execute() File "C:\Users\rober\Anaconda3\lib\site-packages\notion\collection.py", line 411, in execute *kwargs File "C:\Users\rober\Anaconda3\lib\site-packages\notion\client.py", line 294, in query_collection return self._store.call_query_collection(args, **kwargs) File "C:\Users\rober\Anaconda3\lib\site-packages\notion\store.py", line 350, in call_query_collection response = self._client.post("queryCollection", data).json() File "C:\Users\rober\Anaconda3\lib\site-packages\notion\client.py", line 262, in post "message", "There was an error (400) submitting the request." requests.exceptions.HTTPError: Something went wrong.

ErwinGutierrez commented 2 years ago

I have the same error from yesterday. Maybe the API V3 is down?

ghost commented 2 years ago

This is a known issue, and the developer has not updated the application in a couple of years and I’m assuming it’s now dead. I don’t know of any forks from this project that have fixed the issue as folks are now using Notion’s own API.

Notion has its own API (https://developers.notion.com) that’s easy to get into; only disadvantage is that files cannot be uploaded.

david-az commented 2 years ago

It's because of a filter parameter that's not present anymore in the API. For a quick fix, comment the "filter": filter in line 339 in store.py https://github.com/jamalex/notion-py/blob/c9223c0539acf38fd4cec88a629cfe4552ee4bf8/notion/store.py#L339

wsykala commented 2 years ago

Thanks @david-az! If anyone is interested I have updated my fork of the repository with this change.

ErwinGutierrez commented 2 years ago

It's because of a filter parameter that's not present anymore in the API. For a quick fix, comment the "filter": filter in line 339 in store.py

https://github.com/jamalex/notion-py/blob/c9223c0539acf38fd4cec88a629cfe4552ee4bf8/notion/store.py#L339

Thank you David, its worked perfectly!

srepollock commented 2 years ago

@wsykala Thank you for the fix, while it did solve some issues I noticed we were still having some issues with the collections having the filter property and it failing. Here were our commits to fix:

https://github.com/WhitecapRSC/notion-py/tree/master

todaysday commented 2 years ago

@wsykala @srepollock could you please give a clue how to use collections without filter? like i Have this in my code query = workload_table.build_query(filter=filter_query)
But after this fixes I have TypeError: init() got an unexpected keyword argument 'filter'

poiuytrezaur commented 2 years ago

filter field has been renamed to filters, and has a different syntax. removing the filter parameter for the request let you send requests, but disable any filter functionnality

todaysday commented 2 years ago

Do you know any patch to have filter functionality back?

poiuytrezaur commented 2 years ago

Not really. I just checked the requests sent on the website, but I don't know this API well enough to patch itOn Feb 17, 2022 12:53 PM, Safonov @.***> wrote: Do you know any patch to have filter functionality back?

—Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you commented.Message ID: @.***>

todaysday commented 2 years ago

Thanks for the reply. Looks like the only way for my is to migrate to Official Beta API.

srepollock commented 2 years ago

@todaysday looks like the new format is updated here: https://developers.notion.com/reference/post-database-query-filter

// Example:
{
    "filter": {
        "and": [
            {
                "property": "Seen",
                "checkbox": {
                    "equals": false
                }
            },
            {
                "property": "Yearly visitor count",
                "number": {
                    "greater_than": 1000000
                }
            }
        ]
    }
}

I'm sure this could be coded in, but at this point it's an uneeded feature for the time being for our work. We use filters in our databases, just with the API we don't use the filters for now (we need all the data and filter once we have all that data separately).

I'm sure I'll update if/when we add this feature