I'm trying to create a new page in a database in notion. Here is my code:
data = {
"parent": {"database_id": parent},
"properties": {
"Name": {
"title": [{"type": "text", "text": {"content": assignment}}]
},
"Class": {
"rich_text": [
{
"text": {
"content": class_name
}
}],
},
"Due Date": {
"date": {"start": "2021-05-11"}
},
"Tags": {
"multi_select": [
{"name": class_tag}
]
},
"Class Schedule Entry": {
"relation": [
{
"id": assignment_id
}
]
}
}
}
if prof:
data['Professor'] = {
"rich_text": [
{
"text": {
"content": prof
}
}],
}
print(data)
response = requests.request("POST", notion_page_url, json=data, headers=headers).json()
"parent" variable contains the database id and I have confirmed that it is correct. "notion_page_url" variable contains "https://api.notion.com/v1/pages/"
The error that I get is:
{'object': 'error', 'status': 400, 'code': 'validation_error', 'message': 'body failed validation: body.parent.page_id should be not present or a string, instead was null
.'}
According to the docs, we are suppose to include either a database_id or a page_id in parent and I've included a database_id.
Any ideas?