james2017
james2017

Reputation: 23

Curl command on node-red

Could anyone suggest me a way to transform a curl command such as "curl ip:port/a/b -H myHeader1 -H myHeader2 -d '{... JSON FORMAT FILE ...}' " which returns a reply on JSON format on a node-red flow?

Upvotes: 1

Views: 12981

Answers (1)

knolleary
knolleary

Reputation: 10117

The HTTP Request node can be used to make... http requests.

You can pass the node a msg.headers property that contains the HTTP headers to include in the request, and msg.payload will be sent as the body of the request.

Assuming the response contains the appropriate content-type header, the resulting msg.payload will be the JSON parsed into a JavaScript object.

You can see some more examples of the node in the Node-RED cookbook: http://cookbook.nodered.org/http/

Upvotes: 4

Related Questions