I'm able to create a new page using the Notion API, and as part of that page I want to create & include a database table. I'm able to create the page successfully, but when trying to create the database using the child_database block, I am getting a status 400 error. Sample code below. Any help appreciated.
let payload = {
'parent': {'database_id': database_id_variable},
'properties': {
'Name': {
'title': [
{'text': {'content': 'My Grocery List Page'}}
]
}
},
'children': [
{
'object': 'block',
'type': 'child_database',
'child_database': {
'title': 'Grocery List',
'properties': {
'Grocery item': {
'type': 'title',
'title': [{ 'type': 'text', 'text': { 'content': 'Tomatoes' } }]
},
}
}
},
]
}
let response = await fetch('https://api.notion.com/v1/pages', {
method: 'POST',
body: JSON.stringify(payload),
headers: {
'Authorization' : 'Bearer secret_XXX',
'Content-Type': 'application/json',
'Notion-Version': '2021-08-16',
},
});
console.log(await response.json());
}
While not a child database, I was able to resolve my issue by creating a simple table instead since Notion just announced the API would now support simple tables: