Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
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());