0

I'm trying to use an HTTP request to filter entries from a Notion database. There are currently built-in Zapier actions for creating, updating, and finding a database item, but not multiple and not with params.

Currently, I can retrieve all database items with a POST request that looks like this:

https://api.notion.com/v1/databases/[database_id]/query

Notion provides the following format to query and filter items

https://api.notion.com/v1/databases/[database_id]/query?filter_properties=[property_id_1]&filter_properties=[property_id_2]

I'm trying to filter two properties: the checkbox property that's named "Approved", and a single-select property named "Episodes". Retrieving all database items in Zapier shows the property IDs should be IJGI and bacf6208-4106-4e4c-9caa-7780af3f74d5, respectively.

Screenshot of Notion API request test data

From my understanding, this means my query should look something like this:

https://api.notion.com/v1/databases/[database_id]/query?filter_properties=lJGI&filter_properties=bacf6208-4106-4e4c-9caa-7780af3f74d5

Tests unfortunately keep yielding error 400 and the note: The schema for the database with the following ID is malformed.

I have double-checked that my database ID is correct, my database is shared with my integration, and headers include authorization, content-type, and notion-version.

Screenshot of Zapier Notion API request URL

Screenshot of Zapier Notion API request with headers

I have also tried a variety of other more traditional query string formatting types, such as /query?checkbox=true. All yielded error messages.

1 Answers1

0

I believe that the error is probably referring to the database id in the url, the url should look like this https://api.notion.com/v1/databases/897e5a76ae524b489fdfe71f5945d1af/query, not like https://api.notion.com/v1/databases/897e5a76-ae52-4b48-9fdf-e71f5945d1af/query

But I also see that you are not providing the filter in the correct way, what you are looking for is the filter body parameter, not the filter_properties query parameter.

So your url should just be https://api.notion.com/v1/databases/897e5a76ae524b489fdfe71f5945d1af/query and your body (labelled as 'data' by zapier) should look something like this:

{
  "and": [
    {
      "property": "Approved",
      "checkbox": {
        "equals": true
      }
    }, 
    {
      "property": "Episodes",
      "select": {
        "equals": "React"
      }
    },
  ]
}

All the filter conditions are documented here: https://developers.notion.com/reference/post-database-query-filter

And this way you can avoid using property ids that can be more confusing.

Matteo
  • 36
  • 4