Newer Version Available
REST Header Examples
Use these examples to understand REST headers.
REST headers in the Tooling API WSDL are described in REST Headers for Tooling API. For more details about REST Resources, see the REST API Developer Guide.
Examples
The following examples use Apex to execute REST requests with headers. You can use any standard REST tool to access Tooling REST API.
First,
set up the connection to your org and the HTTP request
type:
1HttpRequest req = new HttpRequest();
2req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
3req.setHeader('Content-Type', 'application/json');At the end of each request, add the following code to send the request and retrieve the
body of the
response:
1Http h = new Http();
2HttpResponse res = h.send(req);
3system.debug(res.getBody());