Skip to content

Instantly share code, notes, and snippets.

@tyoshikawa1106
Created May 19, 2015 04:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyoshikawa1106/03cc765344830c5552bf to your computer and use it in GitHub Desktop.
Save tyoshikawa1106/03cc765344830c5552bf to your computer and use it in GitHub Desktop.
Apex Rest API Sample
Http http = new Http();
HttpRequest req = new HttpRequest();
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionId());
req.setHeader('Content-Type', 'application/json');
req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm() + '/services/data/v32.0/query?q=SELECT+Id+,+Name+,+AccountNumber+FROM+Account');
req.setMethod('GET');
HttpResponse res = http.send(req);
System.debug(res);
String result = res.getBody();
System.debug(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment