Skip to content

Instantly share code, notes, and snippets.

@regularcoder
Created September 23, 2016 18:28
Show Gist options
  • Save regularcoder/7ed76c68c1e8a852da60deb41f97482d to your computer and use it in GitHub Desktop.
Save regularcoder/7ed76c68c1e8a852da60deb41f97482d to your computer and use it in GitHub Desktop.
Force.com Tooling API REST quickstart
//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