APIs & Integrations

CRnD
Participant

Handling different filters formats across different endpoints

Hi!

I am using two endpoints in the v3 API:

1. The "lists" one where I get an object type ID and the filters of a list

2. The "objects/X/search" endpoint that helps me query the list's data absed on the object type ID and the filters from a the previous request.

The problem is that the filter format that returns from the "lists" request is different than the expected one in the "objects/X/search" one. Thus, I can't use the given format in the second request.

Is there a way to use one format for both? Or shouldI  work on a way to convert it myself?

Thank you very much!

0 Upvotes
3 Replies 3
CRnD
Participant

Handling different filters formats across different endpoints

Hey, still waiting for a response:)

0 Upvotes
Jaycee_Lewis
Community Manager
Community Manager

Handling different filters formats across different endpoints

Hey, @CRnD 👋 Can you share an example of the response for your first call along with a simple request for your second call, please? Along with the full error body? Having more info can help our community members with answering your question. 

 

Thanks! — Jaycee

linkedin

Jaycee Lewis

Developer Community Manager

Community | HubSpot

0 Upvotes
CRnD
Participant

Handling different filters formats across different endpoints

Hi Jaycee, of course:)
The first "lists" call returns a json that contains a "filterBranch" parameter of this format:

"filterBranch": {
"filterBranches": [
{
"filterBranches": [],
"filters": [
{
"property": "notes_last_updated",
"operation": {
"operator": "IS_AFTER",
"includeObjectsWithNoValueSet": false,
"timePoint": {
"timeType": "DATE",
"timezoneSource": "CUSTOM",
"zoneId": "US/Eastern",
"year": 2024,
"month": 7,
"day": 1,
"hour": 23,
"minute": 59,
"second": 59,
"millisecond": 999,
"timeType": "DATE"
},
"endpointBehavior": "EXCLUSIVE",
"propertyParser": "VALUE",
"type": "TIME_POINT",
"operationType": "TIME_POINT"
},
"filterType": "PROPERTY"
}
],
"filterBranchOperator": "AND",
"filterBranchType": "AND"
}
],
"filters": [],
"filterBranchOperator": "OR",
"filterBranchType": "OR"
}

The "search" request requires a different format as shown in the API, under the search endpoint here.
When I try to use the format that I got in the first reauest, I get this error: 
{
"status": "error",
"message": "Invalid input JSON on line 36, column 29. Some required fields were not set: [propertyName, operator]",
"correlationId": "a6092eb0-74db-4935-8651-20b9407c0fe0",
"category": "VALIDATION_ERROR"
}
 
The difference is not only between the key names (propertyName, operator), the values are expected to be in different formats as well.
For example: The "IS_AFTER" operator value in the first call is equivalent to "GT" in the second one.
 
If you need more data, just tell me:)
Thank you very much!
0 Upvotes