4

Here's the error:

Client warn: request fail { code: 'validation_error', message: 'body failed validation. Fix one: body.properties.body.id should be defined, instead was undefined. body.properties.body.name should be defined, instead was undefined. body.properties.body.start should be defined, instead was undefined.' } body failed validation. Fix one: body.properties.body.id should be defined, instead was undefined. body.properties.body.name should be defined, instead was undefined. body.properties.body.start should be defined, instead was undefined

Here's my code :

async function update() {
  const res_2 = await notion.databases.query({ database_id: `${databaseId}` });

  res_2.results.forEach(async (page, index) => {
    let property_id = page.properties.Excerpt.id;
    if (index === 0) {
      try {
        const res_3 = await notion.pages.update({
          page_id: page.id,
          properties: {
            [property_id]: {
              type: "rich_text",
              rich_text: {
                "content": "hey"
              }
            }
          }
        })

      } catch (err) {
        console.log(err.message)
      }
    }
  })
}
update();

I am not getting why there is a body validation error and from where it originated. Any fixes?

murtuzaali_surti
  • 121
  • 1
  • 10

1 Answers1

5

After a little bit of digging, I found out that this error generally occurs when there are missing parameters in the request body. As per the official Notion documentation,

The request body does not match the schema for the expected parameters. Check the "message" property for more details. https://developers.notion.com/reference/errors

I did not construct the object correctly, and that's why I was getting this error.

The correct construction of rich_text_object is as follows:

properties: {
  "Excerpt": {
    "rich_text": [
      {
        "type": "text",
        "text": {
          "content": "hello"
        }
      }
    ]
  }
}

You can find more information here : https://developers.notion.com/docs/working-with-page-content#creating-a-page-with-content

murtuzaali_surti
  • 121
  • 1
  • 10