Python を使用して Notionの入門ガイドを作成していますが、投稿リクエストを送信するたびに次のエラーが発生します。
{'object': 'error', 'status': 400, 'code': 'invalid_json', 'message': 'Error parsing JSON body.'}
ここで私が自分のコードで試したこと:
# Notion Application
import json, requests
file = open('SECRETS.json') # Opens the file
data = json.load(file) # loads the data then stores in variable called data
# Secret here:
secret = data['id']
# Database information here:
database = data['database_tasks']
file.close() # close file
url = 'https://api.notion.com/v1/pages'
# Headers
headers = {
'Authorization': f'Bearer {secret}',
'Content-Type': 'application/json',
'Notion-Version': '2021-05-13'
}
# Data input
data_input = {
"parent": { "database_id": f"{database}" },
"properties": {
"Name": {
"title": [
{
"text": {
"content": "Yurts in Big Sur, California"
}
}
]
}
}
}
# check request
response = requests.post(url, headers=headers, data=data_input)
print(response.json())
エラーを検索しましたが、何が間違っていたのかわかりません。私は、彼らがウェブサイトで Python 形式で提供した cURL の例に従いました。