Node Red Set POST Parameters for HTTP Request

It is easy to set POST parameters for HTTP request.

The Flow Diagram

node red set post parameters for http request flow diagram
node red set post parameters for http request flow diagram

Steps To Set Get Parameters

1) Inject Node

– Payload – can set to anything. In my case I use timestamp

node red inject node
node red inject node

2) Function Node

– Set POST parameters value here
– msg.headers must set the content type.
– All the POST parameters are set inside msg.payload and the parameter names must correspond to RESTFUL API that you query.

msg.headers={ 
    'Content-Type': 'application/x-www-form-urlencoded'
};
msg.payload = {};
msg.payload={ 
    'ID': 1159
};
node red - function node setting post parameters for http request
node red – function node setting post parameters for http request

3) HTTP Request Node

– Choose method: POST
– Set the correspondent RESTFUL endpoint.

node red - http request node properties
node red – http request node properties

4) Debug Node

– Use to display the output

node red http request post output
node red http request post output

Notes:

Node Red version used – v0.20.7