我正在测试概念 API,我想从 Apps Script 将数据推送到我的 Notion 表中。这是我到目前为止得到的代码和下面的错误。我假设我的 json 结构不正确,但我不知道如何修复它
function tryout_notion () {
const url = "https://api.notion.com/v1/pages";
//tried with : https://api.notion.com/v1/databases
var options = {
'muteHttpExceptions': true,
"method" : "post",
"headers": {
Authorization: `Bearer secret_*****`,
"Content-Type": "application/json",
"Notion-Version": "2021-05-13",
},
"parent": {
"page_id": "*****"
//tried with : "database_id"
},
"properties": {
"Name": {
"title": [
{
"text": {
"content": "CREATE NEW LINE IN NOTION"
}
}
]
}
}
};
const response = UrlFetchApp.fetch(url, options);
Logger.log(response);
}
{"object":"error","status":400,"code":"validation_error","message":"body failed validation: body.parent should be defined, instead was `undefined`."}