See HTTP request in browser inspector or other way of verbose debug

#1

Hi there

I'm trying to get some data from API endpoint that is not well documented but it has been reverse engineered. I can easily make proper call using any known tool as curl or browser inspector.
However, when I'm recreating such call in Node-RED, I get err500 from the server. I assume that required header (content-type) is not reaching that endpoint as it behaves in the same way when I miss it using tools mentioned above.

Below is a simple flow for testing that. I should get timestamp, instead I get err500. Now the main question - is there a way to actually see what is being sent to that URL? I assume node.js is calling it in the background that's why I can't see that request in the browser inspector. I'm googling this for the last 3 days and decided to ask the community.

Summary for the API:
POST http://www.peka.poznan.pl/vm/method.vm?ts=666
with data: {method: 'getServerTime', p0: '{}'}
return: timestamp

Any hint on how to make this flow getting the proper response would be great.
Thanks

[{"id":"980a3a92.b87cc8","type":"inject","z":"90e2ad1d.c627e","name":"Function data","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":190,"y":100,"wires":[["afd450eb.bfe738"]]},{"id":"10c8d06a.412198","type":"http request","z":"90e2ad1d.c627e","name":"Query PEKA","method":"POST","ret":"txt","url":"http://www.peka.poznan.pl/vm/method.vm?ts={{timestamp}}","tls":"","x":610,"y":100,"wires":[["ccf2244b.1ee938"]]},{"id":"afd450eb.bfe738","type":"function","z":"90e2ad1d.c627e","name":"set payload and headers","func":"msg.headers = {'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'};\nmsg.timestamp = new Date().getTime();\nmsg.payload = {\n    method: 'getServerTime',\n    p0: {}\n};\nreturn msg;","outputs":1,"noerr":0,"x":390,"y":100,"wires":[["10c8d06a.412198"]]},{"id":"ccf2244b.1ee938","type":"debug","z":"90e2ad1d.c627e","name":"output","active":true,"console":"true","complete":"true","x":780,"y":100,"wires":[]}]
#2

if you want to set message headers look at the example on this page https://cookbook.nodered.org
(http requests set a request header)

#3

Yes, my example is based on the one you provided yet still not working.

#4

Ok, I'll answer myself. Maybe it will be helpful for others.

When setting content-type to application/x-www-form-urlencoded, we also need to encode body to this form. Passing JSON is not correct (and that was my issue). After changing the format to urlencoded key1=value1&key2=value2 everything started to work.

Anyway, thanks for the input.
Cheers!

PS
The main question is still unanswered. How to see actual HTTP request for debugging purpose. Might be helpful in the future.