Outgoing HTTP Requests

HTTP Requests are Actions that send a payload to an external API. The app currently supports GET, POST, PUT, PATCH and DELETE for HTTP Requests. The Response from the HTTP Request can be processed using either a Custom Action response, a HTTP Response Workflow, or used later in the Workflow via  exec. All methods are explained below.

Making HTTP Requests specifically to the Shopify API should be done using the Shopify REST API Action or Shopify GraphQL Action, rather than the generic HTTP Request Action detailed below.  

Adding an HTTP Request Action

  1. From within the app, click on Workflows in the left sidebar.
  2. Click the title of the Workflow to add the Action to.
  3. From the Workflow page, click + Add Action.
  4. Under the Arigato group, click Send an HTTP Request and click Add Action.

Configuring an HTTP Request Action

All fields in the HTTP Request Action configuration support custom code using Twig and Tokens (variables). Check the Code Reference for more information on custom coding. 
Method
Choose the HTTP method (GET, POST, PUT, PATCH, or DELETE) according to your requirements.
URL
Enter the URL endpoint to send the request to, including "http://" or "https://".
Headers
Add custom headers as needed. Headers can include "Content-Type" or "Authorization". See below for additional information regarding Basic HTTP Authorization.
Body Data
Enter the payload in JSON format if required. See content linked below for additional information regarding formatting JSON data.

Handling the Response

You can handle the response in several ways:

  • Ignore the Response: Do nothing with it.
  • Process with a HTTP Response Workflow: Trigger a separate Workflow to handle the response data.
  • Use a Custom Action: Write Twig code to process the response within the same Workflow.
  • Store the Response in exec for Later Use: Save the API response to exec so it can be reused by other Actions, Conditions, or email templates later in the same Workflow execution.

Using HTTP Response Data Later In A Workflow With exec

Using exec is particularly helpful if you need to access the response data from other parts of the Workflow without repeating the HTTP call. 

Simply select  Use Response in other Actions or Conditions. The Action itself will provide a specific statement to use in the workflow, such as: 

{{ exec["537eeb63-2a04-4e21-9179-e6d11512b7dd"].response | debug }}

The example above is merely the ID of the Action with a statement to dump all of the data that was saved to it. Modify the statement to suit your response and your Workflow. For example, if the response payload included data in a key of "name", the statement would be modified to use it like this and perhaps the statement would be placed in an email Action later in the workflow, like this:

Dear {{ exec["537eeb63-2a04-4e21-9179-e6d11512b7dd"].response.name }},

Important: Data stored in  exec only persists for the duration of the Workflow run. It is not saved between Workflow executions.

Adding Basic Authentication to an HTTP Request Action

Basic Authentication using Base64

This method is the most secure as it does not store the credentials in plain text.

  1. From within a Workflow, click on the HTTP Request Action.
  2. In the configuration panel for the Action, navigate to the Headers section.
  3. Enter the credentials. See below for additional information.

Using the Base64 method, credentials should be formatted as below, where  <credentials> is the Base64 encoding of the username and password joined by a single colon :. For example: 

 Authorization: Basic <credentials>

Generating a Base64 Encoded String
There are many methods of generating a Base64 encoded string including base64encode or Basic Auth generator

Basic Authentication using Plain Text

  1. From within a Workflow, click on the HTTP Request Action.
  2. In the configuration panel for the Action, navigate to the URL section.
  3. Adjust the URL to include the username and password at the beginning of the URL. For example: 
 http://username:password@example.com/

HTTP Response Workflows

Refer to the article titled Handling HTTP Responses, linked below.

HTTP Response Custom Action

Refer to the Code Reference section on Custom Actions and on HTTP Requests in Custom Actions

Related Documentation