postmannotion-api

Adding pages to a multi-column notion database works flawlessly sometimes and gives a validation error sometimes for the same input


Basically, I'm using Postman to send POST requests to

https://api.notion.com/v1/pages

It works for 70% of the times and rest of the times it gives the following error sometimes. That is, for the same input.

{
    "object": "error",
    "status": 400,
    "code": "validation_error",
    "message": "body failed validation. Fix one: body.parent.type should be not present, instead was `\"database_id\"`. body.parent.page_id should be defined, instead was `undefined`."
}

Here's how my body starts

{
    "parent": {
        "type": "database_id",
        "database_id": "a94c42320ef04b6a9c1a7e5e73455557"
    },
    "properties": {
        "Title": {
..................

I'm not posting the entire body because it works flawlessly sometimes.

Please help me out. Is there a way to check logs of the requests that come to my page?


Solution

  • The issue was with having "type: database_id" inside "parent" in the request data.

    {
        "parent": {
            "type": "database_id",(REMOVE THIS LINE)
            "database_id": "a94c42320ef04b6a9c1a7e5e73455557"
        },
        "properties": {
            "Title": {
    ..................
    

    After removing "type" it worked fine. Notion needs to update their docs.