I’m having a weird issue with the Notion API where I’m trying to create new entries in a database using POST requests. The strange thing is that it works most of the time but randomly fails with validation errors even when I’m sending exactly the same data.
Here’s what happens: about 70% of my requests work fine, but the other 30% return this validation error:
{
"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`."
}
The inconsistency is driving me crazy because the same exact request body sometimes works and sometimes doesn’t. Has anyone experienced this kind of intermittent behavior with Notion’s API? Is there some kind of rate limiting or server-side issue that could cause this?
Notion’s API probably has internal routing issues. I’ve seen this where different servers handle requests with slightly different validation rules. Try adding a random 100-300ms delay between requests - fixed it for me during bulk imports. Also double-check your headers, especially notion-version.
I hit the exact same issue building an automation tool that synced data to Notion databases. That validation error screams inconsistency - Notion’s API seems to validate parent object structure differently depending on server load or which instance handles your request.
Here’s what fixed it for me: ditch the explicit parent object format and just use the database_id directly. Yeah, the docs say both formats work, but the simpler approach is way more reliable.
Also check if you’re accidentally hitting different API endpoints or if something in your app is messing with the request body. I found some HTTP libraries get weird with JSON serialization under certain conditions - that’d explain why identical data sometimes gets processed differently.
This issue likely stems from a race condition or caching inconsistencies on Notion’s backend. I have encountered similar intermittent validation errors with their API, primarily related to how their servers process requests. One effective strategy is to introduce a slight delay between consecutive requests, especially during high-frequency operations. Recording the exact timestamp alongside the failed request IDs can help identify patterns that emerge during peak usage times, as the servers may serve outdated validation schemas. Additionally, ensure that you are utilizing the latest API version in your headers; for instance, the version from June 28, 2022, has demonstrated more reliable behavior in database operations. If the problem persists, implementing a retry mechanism with exponential backoff can be beneficial, as many validation problems tend to resolve themselves upon reattempting the request.