Bad implementation when using "Filter" in a Notion database query?

Description:

When attempting to apply a filter for the “tags” field (a relation property) in a Notion database using the API, the filter is not recognized and throws an UnrecognizedKwargsError. This behavior is inconsistent with the documented API, which works correctly when called using curl.

Steps to Reproduce:

  1. Create a Notion database with a relation property (e.g., “tags”).

  2. Attempt to apply the following filter using the API:

{
“property”: “tags”,
“relation”: {
“is_empty”: true
}
}

Error received:
{
“object”: “error”,
“status”: 400,
“code”: “UnrecognizedKwargsError”,
“message”: “filter”
}

using curl, it works correctly:

curl -X POST htt ps://api.notion.com/v1/databases/YOUR_DATABASE_ID/query
-H “Authorization: Bearer YOUR_TOKEN”
-H “Notion-Version: 2022-06-28”
-H “Content-Type: application/json”
-d ‘{
“filter”: {
“property”: “tags”,
“relation”: {
“is_empty”: true
}
}
}’

GPT mentioned:

" The error occurs in the filter section, specifically in handling the relation property. While this format works in curl, it’s being misinterpreted in this environment, causing the UnrecognizedKwargsError related to the filter. This environment may not fully support relation filters."