APIs & Integrations

tonygoodchild
Participante

Searching for contacts

I am trying to use the search API to find contacts based on a partial name search.

 

I've tried using filters with the CONTAINS_TOKEN operator like this:

{"filterGroups":[{"filters":[{"propertyName":"firstname","operator":"CONTAINS_TOKEN","value":"Ton"}]}]}

 

But nothing is ever returned even though there are Contacts named "Tony".

 

So after reading through various forum questions about this I changed and used this:

{"data":"Ton"}

 

However when I do this all contacts are returned no matter what value I search for.

 

Any suggestions?

2 Respostas 2
webdew
Orientador(a) | Parceiro Diamante
Orientador(a) | Parceiro Diamante

Searching for contacts

Hi @tonygoodchild ,

Request Url: https://api.hubapi.com/crm/v3/objects/contacts/search?hapikey={{apiKey}}

Request Body:

{
"filterGroups": [
{
"filters": [
{
"propertyName": "firstname",
"operator": "CONTAINS_TOKEN",
"value": "Ton"
}
]
}
],
"properties": [
"email",
"firstname",
"lastname"
]
}


Hope this helps!


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

Thanks and Regards.

JBeatty
Orientador(a) | Parceiro Diamante
Orientador(a) | Parceiro Diamante

Searching for contacts

Hi @tonygoodchild,

 

After doing some testing with your filter I have found the same issue and a solution. Though I could not find the exact documentation, I was getting correct results by including wild cards denoted by an asterisk in the Value field. For example instead of:

 

{"filterGroups":[{"filters":[{"propertyName":"firstname","operator":"CONTAINS_TOKEN","value":"Ton"}]}]}

 

You should be able to do this:

 

{"filterGroups":[{"filters":[{"propertyName":"firstname","operator":"CONTAINS_TOKEN","value":"Ton*"}]}]}

 

Or this:

 

{"filterGroups":[{"filters":[{"propertyName":"firstname","operator":"CONTAINS_TOKEN","value":"*Ton*"}]}]}

 

Depending on how if you want to match just starting with "Ton" or contains "Ton" at all From my testing this will get the results you need.

 

Best,

Josh

 

Was I able to help answer your question? Help the community by marking it as a solution.

✔️ Was I able to help answer your question? Help the community by marking it as a solution.

Joshua Beatty
Software Developer with Pearagon

Still have questions? Let's Talk