Hi. I am using the hubspot/api-client composer package in my Laravel project. When attempting to obtain a list of clients that have a “Lead Status” of either “Customer” or “In Trial”, the code below produces the error:
[400] Client error: POST https://api.hubapi.com/crm/v3/objects/contacts/search` resulted in a 400 Bad Request response:{“status”:“error”,“message”:"Invalid input JSON on line 1, column 40: Cannot construct instance of java.util.HashSet ( (truncated…))`
If I change the “IN” filter to “EQ” and just send “Customer” as the filter value (and use setValue instead of setValues), it works.
// get all contacts with a "Lead Status" of "Customer" or "In Trial"
$filters[] = [ 'hs_lead_status', 'IN', [ 'Customer', 'In Trial' ] ];
foreach ($filters as $filter) {
$hubSpotFilter = new \HubSpot\Client\Crm\Contacts\Model\Filter();
$hubSpotFilter->setPropertyName($filter[0])
->setOperator($filter[1])
->setValues($filter[2]);
$groupFilters[] = $hubSpotFilter;
}
$filterGroup = new \HubSpot\Client\Crm\Contacts\Model\FilterGroup();
$filterGroup->setFilters($groupFilters);
$searchRequest = new \HubSpot\Client\Crm\Contacts\Model\PublicObjectSearchRequest();
$searchRequest->setFilterGroups([$filterGroup]);
$searchRequest->setLimit(100);
$contacts = $this->_client->crm()->contacts()->searchApi()->doSearch($searchRequest);
Can anybody tell me what I might be doing wrong? Thanks!
Hi, @lifeontime
Thanks for your question.
Looking at the documentation, I think I see the issue and why the EQ operator is working, but IN isn’t. From the documentation — “Included within the specified list. In your request, include the list values in a values array. Inputted values must be in lowercase." Can you try this and see if it works as you are expecting it to, please?
Talk soon! — Jaycee
Hi Jaycee, thanks for your reply. I had tried “customer” and “in trial” in lowercase but had the same outcome. I have just re-tried it to double check but I still get the same error unfortunately.
Hey, @lifeontime
I hope you got this resolved. And I’m going to share an example from Postman where I, finally, got the expected response back. This one made me feel a bit bananas, and I’m still not clear on why it’s behaving this way… 
Steps I took:
-
Added a custom value to Lead Status — Customer (Internal value = Customer)
-
Gave a value for Lead Status to two of my test Contacts:
Jimmy Pesto = In Progress
Montgomery Burns = Customer
-
Tried following the documentation for using the IN operator (using an array, using lowercase values), but it would only return a 200 and no results 
-
Messed around with the EQ filter to make sure I wasn’t fully losing my marbles, and received responses for each individual record
-
Tried using the IN operator again but not using lowercase values and it worked 
Request:
POST https://api.hubapi.com/crm/v3/objects/contacts/search
Request body
{
"filterGroups":[{
"filters":[
{
"propertyName":"hs_lead_status",
"operator":"IN",
"values": ["Customer","IN_PROGRESS"]
}
]
}
]
}
Response
{
"total": 2,
"results": [
{
"id": "1051",
"properties": {
"createdate": "2022-11-04T19:42:16.095Z",
"email": "mburns@snpp.com",
"firstname": "Montgomery",
"hs_object_id": "1051",
"lastmodifieddate": "2024-03-18T15:39:25.028Z",
"lastname": "Burns"
},
"createdAt": "2022-11-04T19:42:16.095Z",
"updatedAt": "2024-03-18T15:39:25.028Z",
"archived": false
},
{
"id": "1801",
"properties": {
"createdate": "2023-06-02T17:08:49.120Z",
"email": "jimmy@jimmypestopizzeria.com",
"firstname": "Jimmy",
"hs_object_id": "1801",
"lastmodifieddate": "2024-03-18T15:11:49.504Z",
"lastname": "Pesto"
},
"createdAt": "2023-06-02T17:08:49.120Z",
"updatedAt": "2024-03-18T15:11:49.504Z",
"archived": false
}
]
}
Why is this working when the documentation states that lowercase values are required for the IN operator? I don’t know. I’ll take it to the team that owns the CRM endpoints, but it may not be a fast process.
If you ignore the documentation and try the above approach, will it return the expected response, @lifeontime?
Best,
Jaycee
Well, I’ve had an absolute shocker here… I’m sorry to have wasted your time (though it does seem you may have found a side-issue whilst investigating), but I have just realised the code is actually working as expected…
The code from my first message is actually from a generic `getContacts` function that accepts an array of `$filters`. You’ll notice that the first line appends to the `$filters` array with the required leads types. My mistake was that the filters I was passing into this function had an operator of “EQ”, so the change from `setValue` to `setValues` was breaking at that point but working for the “IN” operator.
To clarify though, the case of the values must match how they appear within Hubspot, not always be lowercase.
I’m so sorry to have wasted your time and thank you so much for your help looking into it! 
Hey, @lifeontime! You didn’t waste my time at all. I’m glad you located the issue on your end. And I am sure we’ll help others who are searching for an answer and stumble upon our thread. Have a fantastic day! — Jaycee