Contact Search API V3 400 Error

Since a recent update to the beta endpoints this endpoint has stopped working. In postman I can run this:

import hubspot
from pprint import pprint
from hubspot.crm.contacts import PublicObjectSearchRequest, ApiException
client = hubspot.Client.create(api_key="MY API KEY")
public_object_search_request = PublicObjectSearchRequest(filter_groups={"filters":[{"value":"1630047583930","propertyName":"lastmodifieddate","operator":"GT"}]}, sorts="lastmodifieddate", properties=["email","lastname"], limit=100, after=0)
try:
 api_response = client.crm.contacts.search_api.do_search(public_object_search_request=public_object_search_request)
 pprint(api_response)
except ApiException as e:
 print("Exception when calling search_api->do_search: %s\n" % e)

Moving this code to python yields this error:

Exception when calling search_api->do_search: (400)
Reason: Bad Request

HTTP response body: {"status":"error","message":"Invalid input JSON on line 1, column 18: Cannot deserialize instance of `java.util.HashSet` out of START_OBJECT token","correlationId":"10e2f094-6cf0-4470-b006-202883cc687e"}

Any help would be appreciated.

Cheers,

Zack

@taran42 , anything suspicious here?

I don’t see anything that jumps out at me. Maybe there’s something wrong in the JSON that Postman isn’t picking up, but the Hubspot API is?

Hey, I’m facing the same error using the search API endpoint. Can you confirm that the error message is correctly pointing at the JSON?

I tried several variations of JSON input. Every time with the same error. Unfortunately, the API description is not clear to me. Can you please share a valid JSON example that responses something?

Hi @dennisedson , hi @taran42 ,

any update on this topic?

Can you provide me an JSON example that works with the Search Endpoint? Thanks a lot!

Hi @DomiVoglmaier . I do not have a solution to this particular issue. I will have to defer to someone who is more knowledgeable at Python than I.

@DomiVoglmaier , I looked at the docs and have the same python output as @zgod89 did.

From a valid JSON perspective that is not formatted for python, it would look like this

{
 "filterGroups": [
 {
 "filters": [
 {
 "value": "1630047583930",
 "propertyName": "lastmodifieddate",
 "operator": "GT"
 }
 ]
 }
 ],
 "sorts": [
 "lastmodifieddate"
 ],
 "properties": [
 "email",
 "lastname"
 ],
 "limit": 100,
 "after": 0
}

I am unclear what the beta endpoints being used are, though :thinking:

@dennisedsonNow it works for me. Thanks!

@zgod89If you don’t mind, try with additional brackets around filter_groups=[{}] to make it an array. That worked in my python.

public_object_search_request = PublicObjectSearchRequest(filter_groups=[{"filters":[{"value":"1630047583930","propertyName":"lastmodifieddate","operator":"GT"}]}], sorts="lastmodifieddate", properties=["email","lastname"], limit=100, after=0)

Hello.

I am having the same problem with PHP.

<?phpuse HubSpot\Factory;use HubSpot\Client\Crm\Contacts\ApiException;$client = Factory::createWithAccessToken("pat-na1-2bf25c1d-2f5d-4103-af29-xxxxxxxx");$PublicObjectSearchRequest = new PublicObjectSearchRequest(['filter_groups' => [{"filters":[{"value":"foo@gmail.com","values":[],"propertyName":"email","operator":"EQ"}]}], 'sorts' => ["email"], 'properties' => ["email"], 'limit' => 1, 'after' => 0]);try {$apiResponse = $client->crm()->contacts()->searchApi()->doSearch($PublicObjectSearchRequest);var_dump($apiResponse);} catch (ApiException $e) {echo "Exception when calling search_api->do_search: ", $e->getMessage();}

I get the same error with the code copied from the above site.

I would like to have a working PHP code.

---

yoshida