Http Request , Get or Post does it work.

37 views
Skip to first unread message

peter adshead

unread,
Apr 30, 2016, 3:16:44 PM4/30/16
to Node-RED
Hi , Does the Http Request ( input ) work like it says in its own documents  ?

1/ It say , if you name a topic it will add it to the url string , but I can get that to work.
if I name a topic of a injecting "data" and set the url to 127.0.0.1/1880 all I get is the node-red admin page.

2/ it say , to pass a request headers key pair feed in a msg.header  , I can get GET or POST to work , the only way I`ve found is to use a GET form type push eg 127.0.0.1:1880?what=ever

I`ve posted my flow on how I've set them up

Thanks in advance Peter

[{"id":"8a39a88b.d06dc8","type":"http in","z":"76589d77.4d2864","name":"","url":"/data","method":"get","swaggerDoc":"","x":295,"y":235,"wires":[["8ca333d6.6279f","758870bf.14f38"]]},{"id":"8ca333d6.6279f","type":"template","z":"76589d77.4d2864","name":"Page Template","field":"","fieldType":"msg","syntax":"mustache","template":"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n    <title>NODE-RED test</title>\n</head>\n\n<body>\n\nthis is my node-red web page\n\n</body>\n</html>\n","x":585.5,"y":234.00009155273438,"wires":[["41840db1.27577c"]]},{"id":"41840db1.27577c","type":"http response","z":"76589d77.4d2864","name":"","x":879.5833740234375,"y":232.83340454101562,"wires":[]},{"id":"960919e9.0986c","type":"http request","z":"76589d77.4d2864","name":"","method":"GET","ret":"txt","url":"127.0.0.1:1880/data","x":687.5,"y":356.2500305175781,"wires":[["52cbc053.2ef8"]]},{"id":"8d1b5f1e.f5bff","type":"inject","z":"76589d77.4d2864","name":"","topic":"","payload":"{ \"data\" : \"input\" }","payloadType":"json","repeat":"","crontab":"","once":false,"x":331.25,"y":358.7500305175781,"wires":[["8ce8f842.4bf588"]]},{"id":"52cbc053.2ef8","type":"debug","z":"76589d77.4d2864","name":"","active":false,"console":"false","complete":"true","x":880,"y":355.6250305175781,"wires":[]},{"id":"8ce8f842.4bf588","type":"function","z":"76589d77.4d2864","name":"headers","func":"msg.headers = \n{\n\"what\" : \"ever\" \n}\nreturn msg;","outputs":1,"noerr":0,"x":513.75,"y":357.5000305175781,"wires":[["960919e9.0986c","6ad01321.7653cc"]]},{"id":"758870bf.14f38","type":"debug","z":"76589d77.4d2864","name":"","active":false,"console":"false","complete":"true","x":563.75,"y":184.375,"wires":[]},{"id":"6ad01321.7653cc","type":"debug","z":"76589d77.4d2864","name":"","active":false,"console":"false","complete":"true","x":680,"y":311.1250305175781,"wires":[]},{"id":"5746e1fc.88b59","type":"inject","z":"76589d77.4d2864","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":312.5,"y":451.25,"wires":[["7d9f77bd.fde588"]]},{"id":"7d9f77bd.fde588","type":"http request","z":"76589d77.4d2864","name":"","method":"GET","ret":"txt","url":"127.0.0.1:1880/data?what=ever","x":515,"y":451.25,"wires":[["24e7e504.aedf2a"]]},{"id":"24e7e504.aedf2a","type":"debug","z":"76589d77.4d2864","name":"","active":false,"console":"false","complete":"false","x":735,"y":450.625,"wires":[]},{"id":"88e6fc2e.cfc29","type":"comment","z":"76589d77.4d2864","name":"simple server","info":"","x":773.75,"y":187.5,"wires":[]},{"id":"e71527a7.545658","type":"comment","z":"76589d77.4d2864","name":"method 1","info":"","x":516.25,"y":315,"wires":[]},{"id":"3301afad.86b5","type":"comment","z":"76589d77.4d2864","name":"method 2","info":"","x":513.75,"y":407.5,"wires":[]}]

peter adshead

unread,
Apr 30, 2016, 3:21:46 PM4/30/16
to Node-RED
ooooooops , set the first debug node to msg,payload and activate .

Reply all
Reply to author
Forward
0 new messages