Preventing New Database Creation in Notion When Adding a Page

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)

I encountered a similar issue when trying to update an existing page using the Notion API. In my experience, the problem stemmed from the use of both database_id and page_id in the parent object. It is recommended to include only the specific parent identifier that corresponds to the location where the new page is intended to be created. If you want to add a child page under an existing page, just specify the page_id; if you want to add an entry to a database, then include only the database_id. Reviewing the API documentation helped me resolve the issue by adjusting my request body accordingly.

hey luke, i think u r mixing up the parent params. try using only the page_id in the parent instead of both the database and page id; that should only create a page. hope it works for u!