Newer Version Available

This content describes an older version of this product. View Latest

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 Force.com 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.

Salesforce runs on multiple server instances. The examples in this guide use yourInstance in place of a specific instance. Replace that text with the instance for your org.

Note

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());