How to update database Item using the Notion API

Viewed 612

I am currently trying to update a value in a Notion Data base but i am only able to update the header row and not the value fields. Also when getting a specific database using its id only the header values are returned and not the values that are inside the data base. This is the code i am currently using to update the data base header value

payloadUpdateDataBase = {"properties":{"Ticket ID":{"name": "New Ticket ID"},},}

headers = {
"Authorization": "Bearer " + token,
    "Accept": "application/json",
    "Notion-Version": "2022-02-22",
    "Content-Type": "application/json"
}

def updateDatabase():
    response = requests.request("PATCH", urlSingleDataBase, json=payloadUpdateDataBase, headers=headers)
    print(response.status_code)
    print(response.text)

Does any one know how to get/update the values inside the database and not only the headers?

1 Answers

Every entry within a database is a page itself and can be as such manipulated using the usual pages endpoint. By querying the database, you can get the page_id needed to do so. On the other hand, each entry can be treated as a block. If you want to manipulate the content and different child blocks, you can use the page_id as block_id for the blocks endpoint.

Related