HTTP Client
The HTTP node allows you to send http
requests to any endpoint/api/url you want.
This can be useful for tasks such as fetching data from a database, interacting with other services, and sending notifications...
How this node works
this node will simply send an http
request to the desired url and it will save the response so it can be accessible from any other node using the following syntax: koxy.res.{NODE_NAME}
.
How to use this node response
You can use the node response from any other node using the koxy.res.{NODE_NAME}
as described above, and if the response is a JSON or an object you can get the nested values like this (example): koxy.res.{githubsearch.items.0.login}
(this will be the value of the first item's login in the items list).
Add this node to your flow
To add this node to your flow you should open the nodes list. check the flows builder documentation to learn more, and then You should fill the following properties:
name: node names should be unique and can't be changed.
Host url: the url you want to send the request to.
Request method: the method of the request you want to send. can be one of these values:
GET
POST
PUT
PATCH
DELETE
Headers: set your request headers. you can simply add headers by entring the header's key and value and click on Add headers.
Parameters: set your request parameters using this syntax:
q=multineon&page=2
.Body: set the request body in any format you want. remember that the request body can't be used with
GET
requests and will throw an error.Next: the trigger that the node should call after sending the request. click on the
next input
to get a list of available triggers.
Valid body
We left this for you because of the fact that you might use any format in your headers, so if you want to send your body's data you would do it like this:
'{"data": "this is data to be sent"}'
or if you want to send a request using the x-www-form-urlencoded
format your body value should be something like this:
data=this is data&data2=this is data2
Example
Please note that we are not an affliate with Github and this is just an example of how you would use the HTTP Client node.
in this example we will send a GET
request to https://api.github.com/search/users and search for github
itself :)
So first you need to give your node a name, in this example We will name it github1
.
We will set the Host url to https://api.github.com/search/users
and the request method as GET
because We are sending a GET
request.
Now let's set our headers:
We will add one header like this:
Header's key:
Content-Type
.Header's value:
application/json
.
It's time to set our parameters (Remember we can't set a body because We are sending a GET
request):
We will set our parameters as
q=github
.We will leave the request body empty.
And We will set the next trigger
to be stop so we can see what we've done so far and test if our flow is working.
Node structure (example)
The structure of the node we built before would be something like this:
github1: {
type: "http",
icon: "language",
url: "https://api.github.com/search/users",
method: "GET",
headers: '{"Content-Type": "application/json"}',
parameters: "q=github",
data: null,
next: "stop",
x: 0,
y: 0
}
Dynamic variables support
You can use Dynamic variables in the following properties:
host url.
headers.
parameters.
body.
How to add variables to your request's body
For the Koxy simulation system to be able to read your Dynamic variables right (Only in your request body) You will need to set your Content-Type
header based on the format of your request body.
this is simple, the Koxy simulation system will read your variables based on the Content-Type
header's value.