Connection to REST API

Hello,

I'm totally new to Node-Red. I've been doing some research and it seems that Node-Red could help us to achieve what we are trying to do. On one end we have a REST API with information that we want to send to a MQTT Broker. So the idea is to use Node-Red to create a flow for that.

I've been looking at the HTTP REQUEST node but i'm not sure how to connect to the REST API. I need to send a POST message that contains username, password and Database Name.
Then the API will send back a session token that i should use to query the information.

Usually i would send something like this in the Body of the post message:
{"method":"authenticate",
"params":{
"mydatabase":"dbTest",
"myuserName":"user",
"mypassword":"somepasssword"
}
}

Then i would receive something like this:
{
"result": {
"credentials": {
"mydatabase": "dbTest",
"sessionId": "yaHsMj9f0Fz0WSv3a8UhRGA",
"userName": "user"
},
"location": "ThisServer"
},
"version": "3.2"
}

Can someone point me to where i should look to be able to do this ? Since i need to define the database name to where we connect i imagine i cannot use the default authentication option of the HTTP REQUEST node ? Would i need to first build the message and push that into the HTTP node ?

Thank you

Hi and welcome to the forum

You would set the body of the request in msg.payload, then set the url in the http node or feed it in using msg.url, setting the request node to post.
So try adding your body in an inject node using the json type input and pass that to the request node.

Thank you for the information. I will take a look and if i have more question i will come back :stuck_out_tongue: