with Notion API and node.js, I'm trying to update database properties, especially the checkbox property, for my routine ToDo tasks checker.
But I couldn't find the correct way to do so. Error messages say my setting of the checkbox property isn't correct, but I couldn't find the right way in the Notion API documents.
Here's my code:
const { Client } = require("@notionhq/client");
require("dotenv").config();
const notion = new Client({ auth: process.env.NOTION_KEY });
const databaseId = process.env.NOTION_DATABASE_ID;
const uncheckRoutineTasksTodo = async () => {
const response = await notion.databases.update({
database_id: databaseId,
icon:{//Worked
type:"emoji",
emoji:""
},
properties: {
Done: {
checkbox: false,
},
},
});
console.log(response);
};
uncheckRoutineTasksTodo();
And error messages are:
@notionhq/client warn: request fail {
code: 'validation_error',
message: 'body failed validation. Fix one:\n' +
'body.properties.Done.number should be defined, instead was `undefined`.\n' +
'body.properties.Done.formula should be defined, instead was `undefined`.\n' +
'body.properties.Done.select should be defined, instead was `undefined`.\n' +
'body.properties.Done.multi_select should be defined, instead was `undefined`.\n' +
'body.properties.Done.relation should be defined, instead was `undefined`.\n' +
'body.properties.Done.rollup should be defined, instead was `undefined`.\n' +
'body.properties.Done.title should be defined, instead was `undefined`.\n' +
'body.properties.Done.rich_text should be defined, instead was `undefined`.\n' +
'body.properties.Done.url should be defined, instead was `undefined`.\n' +
'body.properties.Done.people should be defined, instead was `undefined`.\n' +
'body.properties.Done.files should be defined, instead was `undefined`.\n' +
'body.properties.Done.email should be defined, instead was `undefined`.\n' +
'body.properties.Done.phone_number should be defined, instead was `undefined`.\n' +
'body.properties.Done.date should be defined, instead was `undefined`.\n' +
'body.properties.Done.checkbox should be an object, instead was `false`.\n' +
'body.properties.Done.created_by should be defined, instead was `undefined`.\n' +
'body.properties.Done.created_time should be defined, instead was `undefined`.\n' +
'body.properties.Done.last_edited_by should be defined, instead was `undefined`.\n' +
'body.properties.Done.last_edited_time should be defined, instead was `undefined`.\n' +
'body.properties.Done.name should be defined, instead was `undefined`.'
}
As messages suggest, I tried to transform the checkbox property to object, but the result was the same.
properties: {
Done: {
checkbox: {
checkbox:false
}
},
},
body.properties.Done.checkbox should be an object, instead was `false`.
Does someone know how to set checkbox property correctly? Please bail me out…