Hey folks, I’m struggling with the Notion API. I can create a page just fine, but when I try to add info to a database on that page, I hit a wall. Here’s what’s going on:
I made a function to create a page, and it works great. But when I use another function to add a row to the database on that page, I get a 404 error. The message says it can’t find the database, even though it’s on the page I just created.
Here’s the weird part: the error mentions that the database isn’t shared with my integration, even though it should be. I’m using the same access token for both tasks. Any ideas on what I might be doing wrong? I’m totally stumped!
def make_notion_page(token, template_id, db_id):
# Code to create page (works fine)
pass
def add_to_notion_db(token, db_id, props):
# Code to add row (fails with 404)
pass
# The add_to_notion_db function fails with:
# Error: Could not find database with ID: [some-id]
# Make sure the relevant pages and databases are shared with your integration.
I encountered similar issues with the Notion API before. What I learned is that the permissions for creating a page and for modifying a database are handled separately. Even if the integration can create a page, it might not have the rights to update the database on that page. It helps to verify that the integration has explicit access to the database and to ensure that the correct database ID is used. Sometimes inserting a short delay after page creation can make a difference. In my experience, checking accessibility with the search endpoint or regenerating the token also turned out to be useful.
hey there! i had a similar problem. make sure ur using the right database ID. sometimes the ID of the database on the new page is different from the template. try getting the database ID after creating the page, then use that for adding rows. also, double-check ur integration permissions in notion settings. good luck!
Have you double-checked that you’re using the correct database ID in your add_to_notion_db function? It’s easy to mix up IDs, especially if you’re working with multiple databases. Another thing to consider is the timing of your API calls. Sometimes, there’s a slight delay between creating a page and the database becoming fully accessible. You might want to add a short sleep or retry mechanism after creating the page before attempting to add rows to the database. Lastly, ensure your integration has the necessary permissions for both page creation and database modification in your Notion workspace settings. These steps have helped me troubleshoot similar issues in the past.