Send HTTP request to a web form

1,054 views
Skip to first unread message

Thomas Lété

unread,
Apr 8, 2016, 2:45:51 PM4/8/16
to Node-RED
Hi everyone,

I'm trying to send post data to a webpage that only accept application/x-www-form-urlencoded data.

Unfortunately, I found nothing about this particular case on the web so I'm dropping this message here hoping someone could help...

My flow is simple : I made a button that send payload (url encoded form data) to HTTP (post) request node then get the respond in HTML node (extract a particular element the exists only when the form is posted) then show its contents to the debug console.
But the required element is not present, meaning the form has not been "posted" by Node-red...

Here is my flow to make you test :


[{"id":"dc340531.b64a48","type":"http request","z":"bb09978a.8fd18","name":"Solar request","method":"POST","ret":"txt","url":"http://www.meteoservices.be/fr/be/home/meteo/panneaux-solaires.html","x":316.5,"y":354,"wires":[["fe5881dd.45de9"]]},{"id":"e092d174.59d93","type":"inject","z":"bb09978a.8fd18","name":"Test in solar","topic":"Test in solar","payload":"Zipcode=7060&PanelWP=240&NoOfPanels=2&Slope=12&Azimuth=155","payloadType":"str","repeat":"","crontab":"","once":false,"x":113.5,"y":354,"wires":[["dc340531.b64a48"]]},{"id":"fe5881dd.45de9","type":"html","z":"bb09978a.8fd18","name":"Extract data","tag":".tx-mgpvinstallation-pi1 table","ret":"html","as":"multi","x":505.5,"y":353,"wires":[["3c4b8672.124e42"]]},{"id":"3c4b8672.124e42","type":"debug","z":"bb09978a.8fd18","name":"","active":true,"console":"false","complete":"false","x":701.5,"y":353,"wires":[]}]

Thanks for your help !

Thomas Lété

unread,
Apr 8, 2016, 3:00:16 PM4/8/16
to Node-RED
Ok I found a way to fix it :-)

I had to add a function node that adds Content-type headers !


[{"id":"dc340531.b64a48","type":"http request","z":"bb09978a.8fd18","name":"Solar request","method":"POST","ret":"txt","url":"http://www.meteoservices.be/fr/be/home/meteo/panneaux-solaires.html","x":316.5,"y":354,"wires":[["fe5881dd.45de9"]]},{"id":"e092d174.59d93","type":"inject","z":"bb09978a.8fd18","name":"Test in solar","topic":"Test in solar","payload":"Zipcode=7060&PanelWP=240&NoOfPanels=2&Slope=12&Azimuth=155","payloadType":"str","repeat":"","crontab":"","once":false,"x":113.5,"y":354,"wires":[["aec7c63a.1dc008"]]},{"id":"fe5881dd.45de9","type":"html","z":"bb09978a.8fd18","name":"Extract data","tag":".tx-mgpvinstallation-pi1 td","ret":"html","as":"single","x":505.5,"y":353,"wires":[["3c4b8672.124e42"]]},{"id":"3c4b8672.124e42","type":"debug","z":"bb09978a.8fd18","name":"","active":true,"console":"false","complete":"false","x":701.5,"y":353,"wires":[]},{"id":"aec7c63a.1dc008","type":"function","z":"bb09978a.8fd18","name":"Send data","func":"\nreturn {payload: \"Zipcode=7060&PanelWP=240&NoOfPanels=2&Slope=12&Azimuth=155\", headers: {\"Content-Type\":\"application/x-www-form-urlencoded\"}};","outputs":1,"noerr":0,"x":226.5,"y":430.5,"wires":[["dc340531.b64a48"]]}]

rasp...@gmail.com

unread,
Feb 14, 2017, 3:04:44 AM2/14/17
to Node-RED
Thank you so much!!!!!!! i searched everywhere this is the only post(ironically) that works!!! other suggestions i tried didn't format the headers correctly. how did you come across this solution??
thanks again
Reply all
Reply to author
Forward
0 new messages