Created
October 2, 2019 09:31
-
-
Save olopsman/5dd9d4ad54c9c10c6eebf14c88d293fe to your computer and use it in GitHub Desktop.
Apex Sample REST Callout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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