Unable to filter by status using Notion API in python

274 Views Asked by At

I'm currently working on a program where I filter my items in Notion using the following code:

my_page = notion.databases.query( 
    **{
        "database_id": database_id, 
        "filter": {
            "and": [
                {
                    "property": On_GCal_Notion_Name, 
                    "checkbox":  {
                        "equals": False
                    }
                }
                , 
                {
                    "or": [
                    {
                        "property": Date_Notion_Name, 
                        "date": {
                            "equals": todayDate
                        }
                    }, 
                    {
                        "property": Date_Notion_Name, 
                        "date": {
                            "next_week": {}
                        }
                    }]   
                },
                {
                    "property": "Status",
                    "status": {
                        "equals": "complete"
                    }
                }
            ]
        },
    }
)

Everything works fine when I filter by other types, but when I filter by status, I got the following error message:

body failed validation. Fix one:
body.filter.and[2].title should be defined, instead was `undefined`.
body.filter.and[2].rich_text should be defined, instead was `undefined`.
body.filter.and[2].number should be defined, instead was `undefined`.
body.filter.and[2].checkbox should be defined, instead was `undefined`.
body.filter.and[2].select should be defined, instead was `undefined`.
body.filter.and[2].multi_select should be defined, instead was `undefined`.
body.filter.and[2].status should be defined, instead was `undefined`.
body.filter.and[2].date should be defined, instead was `undefined`.
body.filter.and[2].people should be defined, instead was `undefined`.
body.filter.and[2].files should be defined, instead was `undefined`.
body.filter.and[2].url should be defined, instead was `undefined`.
body.filter.and[2].email should be defined, instead was `undefined`.
body.filter.and[2].phone_number should be defined, instead was `undefined`.
body.filter.and[2].relation should be defined, instead was `undefined`.
body.filter.and[2].created_by should be defined, instead was `undefined`.
body.filter.and[2].created_time should be defined, instead was `undefined`.
body.filter.and[2].last_edited_by should be defined, instead was `undefined`.
body.filter.and[2].last_edited_time should be defined, instead was `undefined`.
body.filter.and[2].formula should be defined, instead was `undefined`.
body.filter.and[2].unique_id should be defined, instead was `undefined`.
body.filter.and[2].rollup should be defined, instead was `undefined`.
body.filter.and[2].or should be defined, instead was `undefined`.
body.filter.and[2].and should be defined, instead was `undefined`.

I'm wondering where did I go wrong?

edit: I found the issue stemmed from notion_client module. When I updated it from version 0.4.0 to 2.0.0, the problem was resolved.

0

There are 0 best solutions below