You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Python调用Notion API按状态过滤失败问题排查

Notion API添加状态过滤后出现Body验证失败的解决方法

我在开发程序时,使用以下Python代码通过Notion API过滤数据库条目:

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"
                    }
                }
            ]
        },
    }
)

单独使用其他过滤条件时一切正常,但添加状态过滤后出现了如下验证错误:

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`.

经过排查,问题出在notion_client模块版本上,将该模块从0.4.0版本升级到2.0.0版本后,验证错误消失,功能恢复正常。


内容的提问来源于stack exchange,提问作者Eddie

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 22:33:15