Choose Http Post node

Hi

I need to make an HTTP POST call, but I'm not quite sure which node to use and where to put my information

I need to make a POST call to http://ubisys-g1-2836/api/v1/devices/d9/e1/Light/OnOff/OnState/

Header value:
The header key "Authorization" with the following value "bearer ocnzAwYT2FvR0IfpwIDqSf5dRJXztIWb7CChkd4blQ4 ="

Body Value:
{"value": false} or {"value": true}

thanks in advance

See HTTP request examples in the cookbook

"Node-RED Cookbook : Node-RED" https://cookbook.nodered.org#http-requests

Thanks.

I cant see how to insert a body in the http request node.

I did try to send a msg.body = {"value": false}; in a function, but that did not work

[{"id":"cb1dfcde.fd153","type":"function","z":"f3ad92f.bcc277","name":"set payload and headers","func":"//msg.payload = \"data to post\";\nmsg.headers = {};\nmsg.headers['Authorization'] = 'bearer ocnzAwYT2FvR0IfpwIDqSf5dRJXztIWb7CChkd4blQ4=';\n//msg.url = \"http://192.168.0.170/api/v1/\";\nmsg.url = \"http://192.168.0.170/api/v1/devices/d9/e1/Light/OnOff/OnState\";\nmsg.method = \"POST\";\nmsg.body = {};\nmsg.body = {\"value\": false};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":390,"y":320,"wires":[["e44209e7.752698"]]},{"id":"dcf34aab.218928","type":"inject","z":"f3ad92f.bcc277","name":"","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":false,"topic":"","payload":"","payloadType":"date","x":200,"y":320,"wires":[["cb1dfcde.fd153"]]},{"id":"e44209e7.752698","type":"http request","z":"f3ad92f.bcc277","name":"post to HttpBin","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":600,"y":240,"wires":[["ee306582.f0dde8"]]},{"id":"ee306582.f0dde8","type":"debug","z":"f3ad92f.bcc277","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":320,"wires":[]}]

Read the built in help by selecting the HTTP request node then looking in the right hand side bar book tab. I'm not near a computer but from memory, set msg.payload with your data.

Thanks it worked with msg.payload

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