Web Request Action

The Web Request action is a fundamental component to connect with your own APIs and third party applications.

Web Request action supports many HTTP methods and allows you to invoke REST APIs, sending and receiving data in text and JSON formats. You can use the flow's attributes as data, put them in the JSON payload or in headers. You can also assign data coming from your API requests back to your attributes, in both text and JSON formats.

Let's take a look at the Web Request anatomy:

 

The Web Request, when invoked, automatically executes the HTTP request using the settings that you see in the picture above. The result is automatically assigned to the “result” attribute. You can optionally remove all the default response attributes - result, status and error - and rename them as you prefer.

The other important part of Web Request is the Body section. Here you setup your JSON to send to your API endpoint. If you set the JSON payload take care to check that the corresponding "Content-type" header is set on “application/json” value.

When creating the JSON document you must consider how you build you JSON document. Rarely your JSON is a simple static document with fixed data. You often want this structure to be dynamic, in other words you want to use as JSON values or properties the attributes that you collected during your flow (i.e. attributes coming from user interactions like Forms or Capture User input or from other API calls using the same Web Request action).

Consider you

  1. Sending attributes in “string” format
  2. Sending attributes in JSON format

As you can see in the image below, feel free to use your flow attributes in your JSON payload but always use the   syntax (we use LiquidJS for attribute rendering) , to correctly render the attribute in the JSON document:

Take note that it is unnecessary to wrap those Attributes outputs in the quotations since the | json filter will add them to. This filter also escapes quotes as need inside those outputs.

You can get back your data from the remote services invokation in text or JSON format. These two are actually the only supported formats available.

The data type is automatically decoded by the response content-type.

In the case of JSON you can get sub fields of your JSON structure using the “." notation, as highlighted in Attributes

For practical reasons we prepared a tutorial in our community, that you can import witha simple click.

Tutorials

 

You can find some interesting tutorial (that you can import with just one click) on our community. There are many tutorials using the the Web Request but the following two are designed for an easy quick start.

Web Request tutorial for POST method (in our community): Connect to Hubspot using a Web Request.

Web Request tutorial for GET method (in our community): Weather.com API call to get city conditions info.

If you have questions about the Web Request or other Tiledesk features feel free to send an email to support@tiledesk.com