Created
May 19, 2015 04:38
-
-
Save tyoshikawa1106/03cc765344830c5552bf to your computer and use it in GitHub Desktop.
Apex Rest API Sample
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
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