Create Data Actions to Connect to REST APIs from Visualization Canvases

You can use HTTP API data actions in a canvas so that when you select a column, it sends the value to a REST API which returns a response from the external website.

You must configure the domain that you're trying to connect to as a safe domain before you create an HTTP API data action. See Whitelist Safe Domains.

  1. Create or open a project and confirm that you’re working in the Visualize area.
  2. Click Menu and then select the Data Actions tab.
  3. Click Add Action and enter a name for the new HTTP API data action. For example, enter HTTP API Example.

    You can add multiple HTTP API data actions.

  4. Click the Type field and select HTTP API.
  5. Click the Anchor To field and select the columns that you want the HTTP API data action to apply to. Don't select measure columns or hidden columns. If you don't specify a value for the Anchor To field, then the data action applies to all data elements in the visualizations.
  6. Click the HTTP Method field and select an appropriate value (that is, GET, POST, PUT, DELETE) to send to the REST API.
  7. Enter the URL for the REST API that starts with http or https and optionally includes replacement tokens.

    Replacement tokens in the URL pass contextual values to a data action (for example, data values, user name, project path, canvas name).

    For example, you can pass a column value (for example, a value for the Category column) to a REST API (for example, the Google books API) using: http://www.googleapis.com/books/v1/volumes?q=${valuesForColumn:"Category"} The value that you select from a cell in the Category column (for example, "Books") passes to the REST API.

  8. If you selected the POST method, a field is displayed where you enter each parameter on a separate line.

    You enter each parameter as a name-value pair with the name and value separated by "=". You can use the same URL token syntax in the name-value pairs as required by the API that you're calling.

    For example:

    • paramName1=paramValue1
    • paramName2=${valuesForColumn:"Product"}
  9. Click OK to save.
  10. Click a data point in the visualization.

    For example, you might select "Books" from the Category column.

  11. Right-click and select HTTP API Example to display the result.

    The selected data-points determine which values to pass to the URL tokens.

    A success or failure message is displayed confirming the REST API has been successfully invoked using the selected value.