---
schema_version: "1"
id: 034adc03ccf0404c5781263f47550ed17d18cc25e5989c92683aa89b0b9bf69f
title: REST Header Examples
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_tooling/intro_rest_header_examples.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/intro_rest_header_examples.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 47a0dafee32b5363bf18e5ab4b18138b02e9cd3d44b854e8752a562cafeeaaeb
description: Use these examples to understand REST headers.
---
# 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](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/intro_api_tooling_rest_headers.htm "Tooling API provides a subset of the REST headers available in REST 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.

![Note](https://developer.salesforce.com/docs/atlas.en-us.api_tooling.meta/api_tooling/images/icon_note.png)

#### Note

The examples in this guide use a production login URL with MyDomainName in place of the org’s My Domain name. The format for sandbox login URLs differs. To use these examples, update the login URL. You can find the My Domain name and My Domain login URL for your org on the My Domain page in Setup.

First, set up the connection to your org and the HTTP request type:

HttpRequest req = new HttpRequest();
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
req.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:

Http h = new Http();
HttpResponse res = h.send(req);
system.debug(res.getBody());