Can't search in contacts via API | Community
Skip to main content
Answered

Can't search in contacts via API

  • Sep 17, 2020 8:48 AM UTC
  • 12 replies
  • 672 views

I am trying this code:

$intercom = new \Intercom\IntercomClient($secretKey);

$intercom->contacts->search([

"query" => $['field' => 'name', 'operator' => '!=', 'value' => 'Alice'],

]);

 

As I understood: "name != Alice" should return all my contacts.

But as result I have exception: Not Found (404) in php-http/client-common/src/Plugin/ErrorPlugin.php line 83

 

What I do wrong?

Best answer by Team V11

For anyone who came across this, it might be that your App's corresponding API version does not match.

 

How to fix:

  1. go to Settings -> Developers -> Developer Hub
  2. Click your app -> Configure -> Basic Information and use 'change version' in API version section

 

Note be aware if you are already using the App's current API version though, since they are not backward compatitable

View original

12 replies

Eric Fitz
Employee
Forum|alt.badge.img+5
  • Employee
  • Sep 17, 2020 1:05 PM UTC

Hey there @user327​, if you want to return a list of all your contacts through our API, you should use this call:

 

$ curl https://api.intercom.io/contacts\

-H 'Authorization:Bearer <Your access token>' \

-H 'Accept:application/json'


  • New Participant
  • Sep 29, 2020 8:19 PM UTC

@eric f11​ Having pretty same problem here, trying to use contact search API, and getting not_found error code in the response, no matter what I'm sending.

Example request:

 

curl --location --request POST 'https://api.intercom.io/contacts/search#39; \

--header 'Accept: application/json' \

--header 'Content-Type: application/json' \

--header 'Authorization: Bearer <my access token>' \

--data-raw '{

 "query": {

  "field": "id",

  "operator": "~",

  "value": "5dbb136fc4de57aec70116bb"

 }

}'


Roy
Top Expert ✨
Forum|alt.badge.img+7
  • Top Expert ✨
  • Sep 30, 2020 8:35 AM UTC

Hello @yurii m11​, If you have a contact ID, Why just not use "Retrieve a contact"?

 

$ curl https://api.intercom.io/contacts/lt;id> \

-H 'Authorization:Bearer <Your access token>' \

-H 'Accept:application/json'

 

 


  • New Participant
  • Oct 6, 2020 9:35 AM UTC

Hi @roy s11​ 

I've used request body with id query just as an example.

In real case I will need to search by custom attribute value. So that my request would look like this:

 

curl --location --request POST 'https://api.intercom.io/contacts/search' \

--header 'Accept: application/json' \

--header 'Content-Type: application/json' \

--header 'Authorization: Bearer <my access token>' \

--data-raw '{

 "query": {

  "field": "custom_attributes.my_attribute",

  "operator": "=",

  "value": "certainValue"

 }

}'

 

So simple ID queries don't fit my needs.


  • New Participant
  • Answer
  • Mar 8, 2021 12:14 PM UTC

For anyone who came across this, it might be that your App's corresponding API version does not match.

 

How to fix:

  1. go to Settings -> Developers -> Developer Hub
  2. Click your app -> Configure -> Basic Information and use 'change version' in API version section

 

Note be aware if you are already using the App's current API version though, since they are not backward compatitable


  • New Participant
  • Mar 27, 2021 7:44 PM UTC

I got the same issue here. @eric f11​ 

And my error looks like this: {'errors': [{'code': 'not_found',

'message': 'The requested resource does not exist; check your path and try again'}],

'type': 'error.list'}

Any help would be really appreciated.


Eric Fitz
Employee
Forum|alt.badge.img+5
  • Employee
  • Mar 29, 2021 11:23 AM UTC

Hey @nora l​, as per @team v11​'s response, is the API version you're calling the same one as used by your app?


  • New Participant
  • Mar 29, 2021 4:18 PM UTC

Thanks for the answer. It's working well now.


Eric Fitz
Employee
Forum|alt.badge.img+5
  • Employee
  • Mar 29, 2021 4:24 PM UTC

I'm glad to hear it!


  • New Participant
  • Apr 13, 2021 8:30 AM UTC

@eric f11​ 

I need a help

When I use the API I am getting the list of leads.

But I need list of users,

  • How can I access list of all users ?
  • How can I keep filters on the list of users like last seen

 

 


Eric Fitz
Employee
Forum|alt.badge.img+5
  • Employee
  • Apr 13, 2021 9:49 AM UTC

Hey @ankit c​, as this is a different question to the one asked in this thread, can I ask that you open a new question for it, please?


  • New Participant
  • Aug 27, 2022 10:35 AM UTC

Could you please explain what do you mean? I'm using version 2.3 (as I can see in developer-hub and still getting not found error: The requested resource does not exist; check your path and try again

UPD: Ok, I found it. Access token is bound to the specific application and its version must be up to date.