Once you have connected to the REST API data source, you can easily write queries and interact with the REST API in the ToolJet application. Follow these steps to get started:
1. Click on the **+ Add** button in the query manager at the bottom panel of the editor.
2. Select **REST API** from the Data Source section.
3. Enter the required query parameters.
4. Click **Preview** to view the data returned from the query or click **Run** to execute the query.
Whenever a request is made to the REST API, a **tj-x-forwarded-for** header is added to the request, the value of the header will be the IP address of the user who is logged in to the ToolJet application. This header can be used to identify the user who is making the request to the REST API.
REST API sends a **JSON** formatted body by default. If you want to send a different type of body, you can enter the appropriate headers in the **Headers** section.
For example, to send a **multipart/form-data** body, you can add the following header:
<imgstyle={{marginBottom:'15px'}}className="screenshot-full img-full"src="/img/datasource-reference/rest-api/form-headers.png"alt="REST API query headers"/>
To obtain an OAuth token via REST API, add the following custom header: <br/>
`Content-Type: application/x-www-form-urlencoded`
:::
## Response Types and Handling
REST APIs can return data in a variety of formats, including **JSON** and **Base64**. JSON is a common format used for data exchange in REST APIs, while Base64 is often used for encoding binary data, such as images or video, within a JSON response.
When the response **content-type** is **image**, the response will be a **base64** string.
ToolJet provides an option to automatically retry REST API requests in case of certain network errors or specific HTTP status codes. By default, this feature is enabled and will retry the request up to 3 times in case of failure. This feature can be toggled on or off at both the data source level and the individual query level. When enabled, retries will occur for the following scenarios:
1. Specific HTTP status codes: 408, 413, 429, 500, 502, 503, 504, 521, 522, 524.
2. Network errors:
- **ETIMEDOUT**: One of the timeout limits was reached.
- **ECONNRESET**: Connection was forcibly closed by a peer.
- **EADDRINUSE**: Could not bind to any free port.
- **ECONNREFUSED**: Connection was refused by the server.
- **EPIPE**: The remote side of the stream being written has been closed.
- **ENOTFOUND**: Couldn't resolve the hostname to an IP address.
- **ENETUNREACH**: No internet connection.
- **EAI_AGAIN**: DNS lookup timed out.
You can configure this feature at two levels:
### Data Source Level
In the REST API data source configuration, you'll find a toggle for **Retry on network errors** This sets the default behavior for all queries using this data source.
In the query builder for each REST API query, you'll find a similar toggle for for **Retry on network errors** under the **Settings** tab. This sets the behavior for that specific query.