Notion: "Search Objects" by passing Database ID as a variable ? or workaround making API call?

I pass a notion database id via a webhook.
I then connect to corresponding Notion database.

After this, i’d like to Search Objects so that I can retrieve only some Pages with a specific filter on a property (eg “Name”=“Peter”).

  1. with already made Notion module ‘Search objects’:
    Search Database Items, I put my webhook variable notion_db_id in the Database ID field.
    But then I cannot use any filter! Nothing appears, and I cannot seem to connect it to the correct properties.values.

  2. making a direct API call
    via a POST request to query a database https://developers.notion.com/reference/post-database-query

I’m struggling to obtain the correct query string.
I thought passing (in the Query field, not mapped) something like

'{
  "filter": {
    "property": "Name",
    "select": {
        "equals": "Peter"
   }
  }
}'

…would work, but i get the following error

Array of objects expected in parameter ‘qs’.

SO, clearly the format of the data i’m passing in the query string is not correct, and I don’t understand why.
it seems to be a correct JSON structure ?

Can somebody give me some idea so that I can filter the pages of the database with an Database ID passed as a variable and not hardcoded?

Thank you

Hi @Aymeric,

What you want to do is send the,


notion-app

  • profile, messages, bookmarks and preferences

Notion: “Search Objects” by passing Database ID as a variable ? or workaround making API call?

Nerd-Zone

notion-app

1

/

2

Aymeric

3

4d

I pass a notion database id via a webhook.
I then connect to corresponding Notion database.

After this, i’d like to Search Objects so that I can retrieve only some Pages with a specific filter on a property (eg “Name”=“Peter”).

  1. with already made Notion module ‘Search objects’:
    Search Database Items, I put my webhook variable notion_db_id in the Database ID field.
    But then I cannot use any filter! Nothing appears, and I cannot seem to connect it to the correct properties.values.
  2. making a direct API call
    via a POST request to query a database Query a database

I’m struggling to obtain the correct query string.
I thought passing (in the Query field, not mapped) something like

'{
  "filter": {
    "property": "Name",
    "select": {
        "equals": "Peter"
   }
  }
}

As part of the BODY not the querystring, so the method is POST, and just use that in Body section.

1 Like

I had the same problem. It is impossible to do this using the Notion API module, but there is a workaround. Instead of using Notion API try using the HTTP module with a basic “Make request”.

Of course, first, you must create an integration in Notion to get the API secret key. It’s just a few clicks.

But there is one trick. You can’t just set the content type in the header for application/json. You need to pick “Body type” = Raw and then set “Content type” for JSON (application/json) again.

Only then your request content is passed to the Notion API as “data”. In the Notion API module, there is no option to do this and the query string is always sent to Notion API as “qs” not “data” and that is the reason it doesn’t work.

Below is a long screenshot with HTTP module proper setting. The API key and database id are blurred.

Take care!

1 Like

Thanks, you helped me a lot to make this work! Greetings from Poland :wink:

3 Likes