Answered

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

  • 14 March 2024
  • 2 replies
  • 38 views

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 

icon

Best answer by Ebenezer.Laleye 20 March 2024, 17:26

View original

2 replies

Userlevel 2
Badge +3

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

Reply