HTTP Post with Parameter and Body

Hello,

i have a problem to do a HTTP Post in Node Red.

I tested the HTTP Post with the porgramm Postman:

Server: https://arche.webuntis.com/WebUntis/jsonrpc.do

Parameter school=EBG

so Postman shows :https://arche.webuntis.com/WebUntis/jsonrpc.do?school=EBG

Postman-Body: (json) (API-documentation)

{
"id":"ID",
"method":"authenticate",
"params":
{
"user":"xy",
"password":"PASSWORD",
"client":"CLIENT"
},
"jsonrpc":"2.0"
}

I got in Postman a good Response.
.

How could i do this Post in NODERED?

A funktion Node should generate the Body-Json.

Greetings

E_T

Try using below code inside a function node. Of course you want to replace the data otherwise the API will not authenticate.

The HTTP request node should have the Method field configured as "-set by msg.method-"

msg.headers = {}
msg.method = "POST"
msg.url = "https://arche.webuntis.com/WebUntis/jsonrpc.do" ;
msg.headers["content-type"] = "application/json"


msg.payload = {
"id":"ID",
"method":"authenticate",
"params":
{
"user":"xy",
"password":"PASSWORD",
"client":"CLIENT"
},
"jsonrpc":"2.0"
};

return msg

Thank you very much.

But where do I the Information: school=EBG?

and now there is an other problem: The node must have sl/TSL-information because it is https and not http.

The TLS-Konfiguiration needs a Certificate, i think normaly in the browser.

Greetings

E_T

So here the solution:

Install https-node
Then URL = https://arche.webuntis.com/WebUntis/jsonrpc.do?school=EBG

Thank you Andrei!

Greeting

E_T

There is no need to install a separate node... The core Request node handles HTTPS.

1 Like

Ok, i will try it!

Thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.