I'm trying to figure out how to use Notion API, but following example in their official documentation return an ungooglable error.
I'm following this docs
and here is my code:
headers = {
'Authorization': f"Bearer {api_key}",
"accept": "application/json",
'Content-Type': 'application/json',
'Notion-Version': '2022-02-22'
}
data = {'children': [{'object': 'block',
'type': 'table',
'table': {'table_width': 4}}]}
response = requests.patch('https://api.notion.com/v1/blocks/d5e1064a-c6aa-49e2-9f25-4111feac84ca/children', headers=headers, json=data)
This returns following error:
b'{"object":"error","status":400,"code":"validation_error","message":"body failed validation: body.children[0].table.children should be defined, instead was `undefined`."}'
But when I add just a heading everything works fine:
data = {'children': [{'object': 'block',
'type': 'heading_2',
'heading_2': {'rich_text': [{'type': 'text',
'text': {'content': 'blah-blah'}}]}}]}
I literally google everything possible with my error or examples of the api usage