Answered

Can't search in contacts via API

  • 17 September 2020
  • 12 replies
  • 352 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?

icon

Best answer by Team V11 8 March 2021, 13:14

View original

12 replies

Userlevel 1

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'

@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"

 }

}'

Userlevel 1
Badge

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'

 

 

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.

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

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.

Userlevel 1

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

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

Userlevel 1

I'm glad to hear it!

@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

 

 

Userlevel 1

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?

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.

Reply