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

调用Notion API的pages.update更新页面提示不存在的body属性校验失败求助

问题原因

你遇到的报错是Notion API请求体结构不符合规范触发的校验失败,报错提示的body相关信息属于API校验逻辑的误导性输出,和你数据库里有没有body属性完全无关,问题出在你构造的两个属性的结构错误:

1. Name(标题类型)属性结构错误

Notion API中标题类型属性的title数组内,每一项的类型是text,内容字段对应的key也是text,你错误写成了rich_text,导致属性解析失败。

2. Project(关联类型)属性结构错误

关联类型属性的relation数组内,每一项需要传关联页面的id,你错误传入了database_id字段,不符合API规范。

修正后的代码

my.updateTask = async function (notion_page_id, name, todoist_project_id, do_date, priority, in_discord) {
  var req_body = {
    page_id: notion_page_id,
    properties: {
      Name: {
        title: [
          {
            text: {
              content: name
            }
          }
        ],
      },
      Project: {
        relation: [
          {
            // 这里改为传关联项目的页面ID,不是数据库ID
            id: my.getProject("todoist_id", todoist_project_id).notion_id
          }
        ]
      },
      Priority: {
        number: priority
      },
      isOnDiscord: {
        checkbox: in_discord
      }
    }
  }
  if (typeof do_date !== 'undefined' && do_date !== null) {
    start_dt = new Date(do_date.date);
    end_dt = new Date(do_date.date);
    end_dt.setHours(end_dt.getHours() + 24);
    req_body.properties.DoDate = {
      date: {
        start: start_dt.toISOString().replace(/Z$/, '+02:00'),
        end: end_dt.toISOString().replace(/Z$/, '+02:00')
      }
    }
  }
  const response = await my.api.pages.update(req_body);
  return response !== {};
}

额外排查建议

如果修正后还有报错,可以先调用notion.databases.retrieve()接口拉取你的数据库结构,对照返回的属性字段格式构造请求体,避免结构匹配错误。

内容的提问来源于stack exchange,提问作者Clarissa De Simoni

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.30 17:27:01