function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SDeoSDeo 

External API call giving "Unsupported media type"

Hi,

 

I am trying to call infoconnect API through apex class and page. But its giving me error "Unsupported media type".

 

Following is my code :

 

Apex class code:

 

public class CalloutSample {  

   public String getData()  {

              Http http = new Http();     

              HttpRequest req = new HttpRequest();     

              req.setEndpoint('https://api.infoconnect.com/v1/companies/615869369?resourcetype=basic&apikey=f4702d2cfc7efcbda07160f3e89b4ea1');     

              req.setMethod('GET');        

              req.setTimeout(30000);            

              req.setHeader('Content-Type', 'application/json');                   

              HttpResponse res = http.send(req);                

              return res.getStatus();                

     }

}

 

Apex page code :

 

<apex:page controller="CalloutSample">      <apex:form >          <apex:outputLabel value="{!Data}" />:      </apex:form>   </apex:page>

The api url works fine when calling directly from browser.

 

Please help me out...

 

Thanks