Ortali
Ortali

Reputation: 1

'object_not_found, Could not find database with ID' Error When Accessing Linked Databases

I am working with the Notion API to retrieve children blocks of a page using the following code:

await notionClient.blocks.children.list({ block_id: id });

After fetching the page blocks, I filter for databases with:

const DBs = pageContent.results.filter((db) => db.type === 'child_database');

According to the Notion API documentation, it states, "The Notion API does not support retrieving linked databases. To fetch the information in a linked database, share the original source database with your Notion integration." However, even though my source database is shared with my integration, and I can successfully fetch data from the source database itself, I still cannot access the linked databases. They are recognized by the API but result in an object_not_found error when I attempt to access them.

Here are my questions:

  1. Is there a way to identify linked databases versus child databases through the API, since they both appear similar in the response but behave differently when accessed?

  2. What is the recommended approach to handle or filter out linked databases if the API cannot fetch their content despite the source database being shared with the integration?

  3. Should the documentation be updated to reflect that even if the original database is shared, linked databases may still not be accessible through the API?

Any insights or workarounds to effectively manage linked databases using the Notion API would be greatly appreciated. Thank you!

I tried various methods to access linked databases using the Notion API 1.

await notionClient.databases.retrieve({database_id: dbId});
await notionClient.databases.query({database_id: dbId});
await notionClient.pages.retrieve({page_id: dbId});
  1. Searching for Indicators of Linked Databases: I looked for properties in the API’s response that could signify a database as linked. The only distinguishing feature I found was that linked databases appeared with an empty title in inline views. Based on this, I filtered the databases with the following code to exclude those potential linked databases:
const DBs = pageContent.results.filter((db) => db.type === 'child_database' && db.child_database.title.length > 0);

Upvotes: 0

Views: 55

Answers (0)

Related Questions