HTTP Nodes Tutorial
Introduction
This tutorial will guide you through how to use the following HTTP nodes:
HTTP In - The HTTP In node allows you to create an HTTP endpoint that can receive incoming HTTP requests, enabling flow to respond to web-based triggers.
HTTP Request - The HTTP Request node is used to make HTTP requests to external web services or APIs, enabling your flow to fetch data or interact with remote services.
HTTP Response - The HTTP Response node is used to send HTTP responses back to clients or services that have made requests to your flow endpoints, allowing you to send data or messages as responses.
Tutorial Flow Source Code
To explore the HTTP nodes featured in this tutorial, simply download the attached JSON file below and import it into your flow app.
You can do this by either pressing Ctrl + I
simultaneously or by navigating to the main settings and selecting the Import
option.
Tutorial
HTTP Response Nodes
Every HTTP In node should be connected to one or more HTTP Response Nodes, that would provide the HTTP status code of the call to the client. More information about the HTTP response status codes, can be found: here.
You can set-up the status code in three different ways:
By default, the HTTP Response node status code would be set automatically to an appropriate value. If you want to overwrite it, you can:
Set-up directly the status code in the HTTP Response node dialog window, or
Set-up the
msg.statusCode
from outside the HTTP Response node
HTTP Response Body
If you want to return any payload to the client initiating the HTTP request, you can set the msg.payload
which will be returned to the caller along with the HTTP Status node.
HTTP Request URL and Method
There are two possibilities to set the URL and Method of the HTTP Request nodes:
Setting it up directly in the dialog window of the HTTP Request node
Setting it up outside the HTTP Request node by setting the
msg.url
to set the URL andmsg.method
to set the method.
In the example HTTP Nodes flow that’s attached above, I am setting up the msg.url
in the inject
node using JSONata expression to construct the request URL.
Example:$env("BASE_URL") & "/hello"
would translate to https://flow-qiiopfx378xt8.demo-01.qibb.com/hello
.
BASE_URL
The BASE_URL
is an environmental variable that stores the root address of your flow. This base URL is the starting point for all relative URLs within your application, ensuring consistency and ease of management.
Testing Your API Endpoint
You are encouraged to test your API endpoints through an API client like Postman, Insomnia, curl, or by directly accessing the respective URL from your browser.
Please be aware that your web browser is suitable exclusively for GET requests that do not demand specific headers or authentication.