Notion API APIResponseError: body failed validation

33 Views Asked by At

When trying to add a new entry to a database using Notion's API, I receive these errors. I am trying to send a new entry, with 2 proporties. An owner property, which is a dropdown selection of all the people in the workspace, and a property called Priority, which is a select that has a dropdown selection of a few numbers, 1 to 4.

An example of the properties

APIResponseError: body failed validation. Fix one: body.properties.Priority.type should be not present, instead was "Select". body.properties.Priority.select should be not present, instead was {"value":"1"}. body.properties.Priority.name should be defined, instead was undefined. body.properties.Priority.start should be defined, instead was undefined.

const properties = {
    title: [{
        text: {
            content: "Test"
        }
    }],
    Priority: {
        id: "9~q3",
        type: "Select",
        select: {
            value: "1"
        }
    },
    Owner: {
        people: [{
            email: "[email protected]"
        }]
    }
};
1

There are 1 best solutions below

0
On

I figured how to solve this. You need to follow your database's exact schema as well as follow the Notion's Property Values

This is the fix:

const properties = {
    "Name": {
        "title": [
            {
                "type": "text",
                "text": {
                    "content": data
                }
            }
        ]
    },
    "Priority": {
        "select": {
            "name": "1"
            }
        },
    "Owner": {
        "people": [
            {
                "object": "user",
                "id": "73ff3834-bbfd-4937-9be8-822a67b2994d"
            }
        ]
    }
};```