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

ADD A HEADER

Many APIs require that you include an API key or other authorization as a header. Generally these values will be available in the developer section of your platform, or upon request from your account manager.

There are also many free, open APIs that don’t require any authorization, or request that you pass an API key in the URL instead; in those cases, just leave the header section blank.

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

SYNTAX

The exact values and syntax for the header depend on the authentication type and platform. For example, some platforms will request that you use basic HTTP authentication, where Key = ‘Authorization’, and Value = ‘Basic ‘+ {base64 encoding of an id and password}. (In that case, you can consult this article on Basic Authentication).

The documentation for each API should note exactly what type of header is required.

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 Add Request Body
Next Preview API Response

4 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
    • Generally if you want to display output in a particular cell, you would 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