Issues with contact search via API

Hi,

Were you able to find the problem? I’m experiencing the same thing while searching for persons using ‘email’ as the term. Most times I get the correct result from the API, but there are times that I get 0 results (even if the person exists).

Right now I am calling the API twice to check the results of the first call

Hi @Joao_Paulo_Resende_Montei
Welcome to the community :wave: Seems like a strange behavior with the search API. Are you making use of the ItemSearch endpoint or the Persons >> Search endpoint?

Can you share the request payload structure and the data it’s supposed to retrieve? Let’s look into this in detail :slight_smile:

I am using the [Persons >> Search] endpoint, as shown in this image. The final URL is “https://api.pipedrive.com/v1/persons/search?term=clarissagodprates@gmail.com&fields=email&exact_match=true&api_token=XXXX

To which I expect to receive every person who has “clarissagodprates@gmail.com” on the “emails” field. Like the example below.

{
“success”: true,
“data”: {
“items”: [
{
“result_score”: 0.1997,
“item”: {
“id”: XXXXX,
“type”: “person”,
“name”: “XXXXX”,
“phones”: [“XXXXX”],
“emails”: [“clarissagodprates@gmail.com”],
“primary_email”: “XXXXX”,
“visible_to”: 3,
“owner”: { “id”: 11159393 },
“organization”: null,
“custom_fields”: [],
“notes”: [],
“update_time”: “2023-04-20 10:31:34”
}
}
]
},
“additional_data”: {
“pagination”: {
“start”: 0,
“limit”: 100,
“more_items_in_collection”: false
}
}
}

This is the behavior I see almost every time, but there are situations that I receive an empty result, like this:

{
“success”: true,
“data”: { “items”: [] },
“additional_data”: {
“pagination”: {
“start”: 0,
“limit”: 100,
“more_items_in_collection”: false
}
}
}

This is very rare and I could not figure a way to reproduce it. Right now I am calling the API twice to verify the result, which is not ideal.

This is the snippet of the code I am using:


image