My script wrongly creates a new database instead of updating an existing Notion page. How can I alter the code to add only a page? Revised snippet below:
import json
import requests
def append_entry(db_ref, pg_ref, header_info, endpoint_url):
content = {
"parent": {
"database_id": db_ref,
"page_id": pg_ref
},
"properties": {
"Title": {"text": "Hello World"}
}
}
json_data = json.dumps(content)
resp = requests.post(endpoint_url, headers=header_info, data=json_data)
print(resp.status_code, resp.text)
identifier_db = "abc123db"
identifier_pg = "xyz789pg"
api_url = "https://api.notion.com/v1/pages/"
secret_key = "YOUR_SECRET"
headers = {
"Authorization": "Bearer " + secret_key,
"Notion-Version": "2021-05-11",
"Content-Type": "application/json"
}
append_entry(identifier_db, identifier_pg, headers, api_url)