HTTP(S) action step

Want to use some data from a place that isn't your own application, the HTTP(S) step has you covered.

Updated over a week ago

After reading this article, you'll learn how to:

  • Configure the HTTPS step

  • Retrieve data from a different place

Getting started

The HTTPS step is one of the standard action steps within the action builder. It's also one of the most powerful steps in the standard set of steps since it allows you to connect to a variety of services, be it retrieving-, sending-, updating-, or deleting information.

Before you use the HTTPS step you need to know what you want to do with it. In this article, we'll use a use case in which we'll request a user from another website. We'll use the JSON placeholder fake rest API to achieve this.

To make the example a bit fancier we'll also need the expression step from the block store, make sure to install it before continuing.

Setting up your action

We'll keep this example plain. Create a new action called 'Get user'.

What we want is we want to retrieve 1 user from the JSON placeholder API. We'll retrieve a user based on his ID. To do this what needs to be done is we need to make a 'GET' request to an endpoint, in this case /users/id.

Let's add the user's id as an input variable, this way when we test the action we can simply give the action a variety of id's to test if it works the way we expect. Create this variable in the start step, since URLs are text-based we'll create a text variable called 'user_id'.

We can then add the URL as a variable, this can be a regular variable instead of an input, this is a text variable as well. The value that it will contain is: jsonplaceholder.typicode.com/users/

In the next step, adding an expressions variable to our action, we'll combine the user_id with the url variable.

So drag the expression step which can be installed from the block store into the action flow. Add two variables to the expression step, and name them the same as the variables that we previously created in the start step.

We can then assign the two variables previously created to them and make our expression. What we want to accomplish with the expression is a URL that retrieves 1 user. So all we need to do is combine the url that contains jsonplaceholder.typicode.com/users/ with the user_id that contains whatever number we give it. Resulting in for example: jsonplaceholder.typicode.com/users/7 which will give the information of user with id 7.

The output from the external website is json so we'll need to use the text output type and we'll name the output of the expression output_url.

Configuring the HTTPS step

Let's drag the HTTPS step onto the canvas. Configuring the step is rather self explanatory, the protocol in this case is HTTPS, the URL is the URL that we created above so select our output_url here. We'll use the GET method since we want to retrieve data, and finally the data that we retrieve we'll use that as retrieed_user.

Add the retrieved_user variable to the 'finish' step.

We can now test if our action works. You can for example create a page with a form where you have an input that asks which user you want to retrieve, but for this example let's make use of the playground.

Hit the Test run button and copy the code in the playground. In the query variable section, don't forget to specify which user you want to retrieve here. For this example let's retrieve user 1.

Make sure to wait for your action to compile before hitting the Play button in the playground.

Once you hit the Play button our action will execute and call the JSON placeholder endpoint, which in this case is:

https://jsonplaceholder.typicode.com/users/1

The end result will then look like this:

So in this case user 1 is 'Leanne Graham', if we'd change the query variable to for example 7, JSON placeholder will give us a different user. In that case it'll be 'Kurtis Weissnat'.

With this data, you can now do a variety of things. You can use it in for example a create step. To save the data to your own application, or display the data on your page.

In this example, we use the 'GET' method but with the HTTPS step you can also 'POST' data, or in other words send data. Or even update (PUT), or delete (DELETE) data.

Did this answer your question?