Skip to content

Instantly share code, notes, and snippets.

@olopsman
Created October 2, 2019 09:31
Show Gist options
  • Save olopsman/5dd9d4ad54c9c10c6eebf14c88d293fe to your computer and use it in GitHub Desktop.
Save olopsman/5dd9d4ad54c9c10c6eebf14c88d293fe to your computer and use it in GitHub Desktop.
Apex Sample REST Callout
public with sharing class MyServiceAPI {
@AuraEnabled
public static String getTransactions(String dateFrom) {
HttpRequest req = new HttpRequest();
req.setMethod('GET');
//retrieved from named credentials
request.setEndpoint('callout:MyServiceAPI/transactions?date=dateFrom');
req.setEndpoint(strEndPoint);
req.setHeader('Accept', 'application/json');
Http h = new Http();
HTTPResponse res = h.send(req);
if (res.getStatusCode() == 200) {
return res.getBody();
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment