# Filter with IN operator fails in PHP SDK

**URL:** <https://community.hubspot.com/t/filter-with-in-operator-fails-in-php-sdk/102627>\
**Category:** APIs & Integrations\
**Tags:** php, sdk\
**Created:** [March 14, 2024, 6:23pm UTC](https://community.hubspot.com/t/filter-with-in-operator-fails-in-php-sdk/102627 "2024-03-14T18:23:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lifeontime](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@lifeontime](https://community.hubspot.com/u/lifeontime)\
**Post date:** [March 14, 2024, 6:23pm UTC](https://community.hubspot.com/t/filter-with-in-operator-fails-in-php-sdk/102627/1 "2024-03-14T18:23:35Z")

</div>

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`](https://api.hubapi.com/crm/v3/objects/contacts/search%60) 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.

```lia-code-sample
// 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!

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [March 15, 2024, 4:28pm UTC](https://community.hubspot.com/t/filter-with-in-operator-fails-in-php-sdk/102627/2 "2024-03-15T16:28:45Z")

</div>

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](https://developers.hubspot.com/docs/api/crm/search#:~:text=IN-,Included%20within%20the%20specified%20list.%20In%20your%20request%2C%20include%20the%20list%20values%20in%20a%20values%20array.%20Inputted%20values%20must%20be%20in%20lowercase.,-Refer%20to%20the) — “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

---

<div class="post-metadata">

**Author:** ![lifeontime](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@lifeontime](https://community.hubspot.com/u/lifeontime)\
**Post date:** [March 15, 2024, 4:33pm UTC](https://community.hubspot.com/t/filter-with-in-operator-fails-in-php-sdk/102627/3 "2024-03-15T16:33:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [March 18, 2024, 4:28pm UTC](https://community.hubspot.com/t/filter-with-in-operator-fails-in-php-sdk/102627/4 "2024-03-18T16:28:33Z")

</div>

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`

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

---

<div class="post-metadata">

**Author:** ![lifeontime](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@lifeontime](https://community.hubspot.com/u/lifeontime)\
**Post date:** [March 19, 2024, 8:52am UTC](https://community.hubspot.com/t/filter-with-in-operator-fails-in-php-sdk/102627/5 "2024-03-19T08:52:41Z")

</div>

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! 😖

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [March 19, 2024, 2:37pm UTC](https://community.hubspot.com/t/filter-with-in-operator-fails-in-php-sdk/102627/6 "2024-03-19T14:37:29Z")

</div>

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
