我正在制作一个小脚本来创建一个简单的页面 un Notion。我已经尽可能地恢复和简化了 Notion 文档的cURL 帖子示例,但最终出现以下错误
body failed validation: body.parent should be defined, instead was `undefined`.
我的父母很明确,不是吗?
const DATABASE_ID = "xxxxxxxx";
// refer https://developers.notion.com/reference/versioning
const NOTION_VERSION = "2021-08-16";
function createPage() {
var service = getService();
if (service.hasAccess()) {
let url = "https://api.notion.com/v1/pages";
let data = {
parent: { database_id: DATABASE_ID },
properties: {
Name: {
title: [
{
text: {
content: "CREATE NEW PAGE",
},
},
],
},
}
};
let response = post(service, url, data);
let result = JSON.parse(response.getResponseCode());
if (result !== 200) {
result = JSON.parse(response.getContentText());
console.error(result.status);
console.error(result.message);
} else {
Logger.log("Connexion OK");
}
}
}
function post(service, url, data) {
var options = {
method: "post",
muteHttpExceptions: true,
payload: JSON.stringify(data),
headers: {
"Notion-Version": NOTION_VERSION,
Authorization: "Bearer " + service.getAccessToken(),
},
};
return UrlFetchApp.fetch(url, options);
}```