Search API Connector Documentation

Print

Include Headers

Se below for details on including headers for API Requests using the API Connector add-on for Google Sheets.

Contents

What are API Headers?

Headers are key-value pairs that send extra information about your request to the API server. The server responds with headers as well; it’s a two-way exchange. Headers typically aren’t directly related to the content of the request, but instead provide metadata to describe the request and handle authorization.

There are many custom headers, but here are a few of the most common:

  • Accept. Tells the API server which format you expect to receive back, e.g. text/html, application/xml, application/json.
  • Authorization. Include authorization credentials like an API key or token.
  • Content-type. Describes the format of the current request or response.

Add a Header

Required headers and header values are generally available in the developer section of your platform. The exact values and syntax for the header depend on the API so check the API documentation to see what exactly is required.

To enter a header, enter the key-value pair into the Headers section of the API Connector form.
api-connector-headers-img1

Add Multiple Headers

You may need to include multiple headers in your API request.

Simply add them, one under the other, in the Headers section of API Connector’s Create Request screen:
api-connector-headers-img2

Delete Headers

If you need to delete a header, you may do so by clicking the red “x” icon that appears on hover.
api-connector-headers-img3

Reference a Cell

As an alternative to typing in your headers directly, you can input them into a sheet cell instead, and then reference the cell, e.g. +++Inputs!A1+++ (info).

Previous Connect to a Preset OAuth2 API
Next Add Request Body

5 thoughts on “Include Headers”

  1. The API i’m calling requires that an “Authorization” header is added with “Bearer ” + access_token, however I don’t know how to reference the token provided by the Custom OAuth2 functionality. Is there a way to access the token dynamically?

    Reply
    • Hey Jay! Sure, you can reference the cell containing the token using +++ syntax (info). You can also schedule your requests to run in sequence to make sure that the access token is returned before your second request needs it. However this sounds like you’re setting up OAuth2, in which case the custom OAuth2 feature probably makes more sense since it will refresh the access token for you.

      Reply
    • You can have the raw API data dump to a source sheet, then pull the data you want into cell D29 in a second summary sheet. Sheets provides a lot of functions for this (VLOOKUP is probably the most popular).

      Another option would be our IMPORTAPI custom function, which lets you run API queries from any cell.

      Reply

Leave a Comment

Table of Contents