Skip to main content
Answered

What is the expected format to pass request body while calling https://api.intercom.io/contacts


I am trying to fetch 150  contacts per page while calling  https://api.intercom.io/contacts.

but on trying to do so , i am getting the following error 

{"type":"error.list","request_id":"0069rm2ubh0lgdfr7kg0","errors":[{"code":"invalid_document","message":"either_email_or_user_id_present validation failed"}]}

 

attaching the REST API INTEGRTION code below: ( implemented using Salesforce Apex)

 

String endpoint=’ https://api.intercom.io/contacts

HttpRequest request = new HttpRequest();
 request.setEndpoint(endpoint);
 request.setMethod('GET');
 request.setHeader('Authorization', 'Bearer ' + INTERCOM_API_TOKEN);
 request.setHeader('Accept', 'application/json');
 request.setHeader('Content-Type','application/Json');
      
 Integer perPage = 150; 
 String json= '{'+            
            ' "per_page":'+perPage + 
  '}'; 
  system.debug(json);

 request.setBody(json);

 

Could you kindly share your thoughts on how to handle this error . Any input is highly appreciated .

 

Thank you 

Best answer by Ebenezer.Laleye

Hi @habraham_martellotech.com ! Ebenezer here from Engineering Support👋.

I see a something small that may be the issue.

Could you change; request.setHeader('Content-Type','application/Json'); to request.setHeader('Content-Type','application/json');

Let me know how it goes!

View original
Did this topic help you find an answer to your question?

2 replies

Forum|alt.badge.img+4

Hi @habraham_martellotech.com ! Ebenezer here from Engineering Support👋.

I see a something small that may be the issue.

Could you change; request.setHeader('Content-Type','application/Json'); to request.setHeader('Content-Type','application/json');

Let me know how it goes!


Thanks it worked


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings