# Searching contacts having last name as empty string

**URL:** <https://community.hubspot.com/t/searching-contacts-having-last-name-as-empty-string/43781>\
**Category:** APIs & Integrations\
**Tags:** contacts\
**Created:** [September 14, 2021, 10:43am UTC](https://community.hubspot.com/t/searching-contacts-having-last-name-as-empty-string/43781 "2021-09-14T10:43:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ascavalcante](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ascavalcante/32/92090_2.png) [@ascavalcante](https://community.hubspot.com/u/ascavalcante)\
**Post date:** [September 14, 2021, 10:43am UTC](https://community.hubspot.com/t/searching-contacts-having-last-name-as-empty-string/43781/1 "2021-09-14T10:43:11Z")

</div>

I’m trying to use the endpoint ‘search’ to find contacts having first\_name as empty string. Like we can do in the frontend using the filter where First Name “is unknown”. But I getting the following error:  
Cannot construct instance of `com.hubspot.inbounddb.publicobject.core.v3.search.Filter`, problem: value must be non-empty and non-blank, if specified’

example of request (I’m omiting here the sorts, etc)

curl --request POST \  
--url ‘[https://api.hubapi.com/crm/v3/objects/contacts/search?hapikey=YOUR\_HUBSPOT\_API\_KEY](https://api.hubapi.com/crm/v3/objects/contacts/search?hapikey=YOUR_HUBSPOT_API_KEY)’ \  
--header ‘content-type: application/json’ \  
--data '{  
“filterGroups”: [  
{  
“filters”: [  
{  
“value”: “”,  
“propertyName”: “firstname”,  
“operator”: “EQ”  
}

…  
}

Is there any way to get this info throught the API ?

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [September 14, 2021, 8:34pm UTC](https://community.hubspot.com/t/searching-contacts-having-last-name-as-empty-string/43781/2 "2021-09-14T20:34:53Z")

</div>

@ascavalcante

Instead of query for the equality, you should query to see if the property has a value. Then you can exclude the “value” altogether.

Example:

```lia-code-sample
{
 "filters": [
 {
 "propertyName": "firstname",
 "operator": "NOT_HAS_PROPERTY"
 }
 ]
}

```

Note that I did not use a filter group as I am only querying for one thing

---

<div class="post-metadata">

**Author:** ![ascavalcante](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ascavalcante/32/92090_2.png) [@ascavalcante](https://community.hubspot.com/u/ascavalcante)\
**Post date:** [September 15, 2021, 10:38am UTC](https://community.hubspot.com/t/searching-contacts-having-last-name-as-empty-string/43781/3 "2021-09-15T10:38:09Z")

</div>

It worked just fine! Thanks a lot!

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [September 15, 2021, 12:32pm UTC](https://community.hubspot.com/t/searching-contacts-having-last-name-as-empty-string/43781/4 "2021-09-15T12:32:27Z")

</div>

Hi @ascavalcante ,  
Below php code will help for you  
\<?php  
$data = ‘{  
“filterGroups”:[  
{  
“filters”: [  
{  
“propertyName”: “firstname”,  
“operator”: “NOT\_HAS\_PROPERTY”  
}  
]  
}  
]  
}’;  
$ch = curl\_init();  
curl\_setopt($ch, CURLOPT\_URL, ‘[https://api.hubapi.com/crm/v3/objects/contacts/search?hapikey=YOUR\_HUBSPOT\_API\_KEY](https://api.hubapi.com/crm/v3/objects/contacts/search?hapikey=YOUR_HUBSPOT_API_KEY)’);  
curl\_setopt($ch, CURLOPT\_RETURNTRANSFER, 1);  
curl\_setopt($ch, CURLOPT\_POST, 1);  
curl\_setopt($ch, CURLOPT\_POSTFIELDS, $data);  
$headers = array();  
$headers[] = ‘Content-Type: application/json’;  
curl\_setopt($ch, CURLOPT\_HTTPHEADER, $headers);  
$result = curl\_exec($ch);  
if (curl\_errno($ch)) {  
echo ‘Error:’ . curl\_error($ch);  
}  
curl\_close($ch);  
?\>

Hope this helps!

If we were able to answer your query, kindly help the community by marking it as a solution.  
Thanks and Regards.

---

<div class="post-metadata">

**Author:** ![ascavalcante](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ascavalcante/32/92090_2.png) [@ascavalcante](https://community.hubspot.com/u/ascavalcante)\
**Post date:** [September 15, 2021, 2:13pm UTC](https://community.hubspot.com/t/searching-contacts-having-last-name-as-empty-string/43781/5 "2021-09-15T14:13:46Z")

</div>

Thanks a lot [@webdew](https://community.hubspot.com/t5/user/viewprofilepage/user-id/131510) ! I used the solution provide by dennisedson
