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
richfer_richfer_ 

How to call a external REST api in apex?

I've to make a call to a external REST api from the apex code. Here is the api,

curl https://website.com/v1/customer/searchbyid/<customer_id> -H 'Content-Type: application/json' -H 'Authorization: APIKey'

I would like to call the api and access the returned values in my controller. 
BalajiRanganathanBalajiRanganathan
refer the below url
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_httprequest.htm#apex_classes_restful_http_httprequest

for Json, you can set following in the request
          req.setHeader('Content-type','application/json');    
         req.setHeader('Accept','application/json');