I’ve dealt with this exact issue before, and it can be incredibly frustrating. One thing that’s not immediately obvious is that Notion’s API permissions are quite granular. Even if you’ve connected your database to the integration, you might not have the right level of access.
Here’s what worked for me: I went back to my Notion workspace, found the specific database I was trying to access, and manually shared it with my integration. It’s easy to miss this step because you might assume that connecting the integration at the workspace level is enough.
To do this, open your database in Notion, click the ‘Share’ button at the top right, and select your integration from the list. Make sure it has full edit access. After doing this, my 404 errors disappeared.
If that doesn’t solve it, double-check your database ID. Sometimes, especially if you’ve duplicated databases, the ID can change without you realizing it. You can find the correct ID in the URL when you’re viewing the database in Notion.
I encountered a similar issue recently. One often overlooked aspect is the scope of your integration. When you create a Notion integration, you define its capabilities. If you didn’t select the appropriate permissions during setup, you might face 404 errors.
To rectify this, go to your integration settings in the Notion API dashboard. Ensure you’ve enabled the necessary capabilities, especially ‘Read content’ and ‘Query databases’. After updating the permissions, you may need to reinstall the integration in your workspace.
Another potential cause could be workspace-level permissions. If you’re part of a team, check with your workspace admin to confirm that your integration has the necessary access rights across the entire workspace.
Lastly, verify that your database isn’t in a page with restricted access. Notion’s security model can sometimes prevent API access to content in certain locations within your workspace hierarchy.
hey man, i had the same problem. try checking ur api version. sometimes notion updates it and ur code becomes outdated. also, make sure ur using the right endpoint for querying databases. it should be ‘/v1/databases/{database_id}/query’. if none of that works, maybe try regenerating ur integration token. good luck!