Created
September 23, 2016 18:28
-
-
Save regularcoder/7ed76c68c1e8a852da60deb41f97482d to your computer and use it in GitHub Desktop.
Force.com Tooling API REST quickstart
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
//Submit an HTTP GET request | |
public String getHTTP(String svcURL) { | |
//HTTP objects | |
HttpRequest req = new HttpRequest(); | |
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID()); | |
req.setHeader('Content-Type', 'application/json'); | |
String domainUrl = URL.getSalesforceBaseUrl().toExternalForm(); | |
req.setEndpoint(domainUrl + svcURL); | |
req.setMethod('GET'); | |
Http h = new Http(); | |
HttpResponse res = h.send(req); | |
return res.getBody(); | |
} | |
//Pull layout rows | |
String response = getHTTP('/services/data/v37.0/tooling/query/?q=SELECT+EntityDefinitionID,LayoutType,ManageableState,Name,NamespacePrefix,TableEnumOrID+FROM+Layout+WHERE+TableEnumOrId=\'Account\''); | |
System.debug(response); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment