HTTP request in node-Red

Hi,

I am having a very simple issue.
I am trying to check upon the status of my Daikin Aircon.
When I enter the following in a Chrome web browser:
10.10.10.50/aircon/get_sensor_info
I get following response:
ret=OK,htemp=23.0,hhum=35,otemp=10.0,err=0,cmpfreq=0

I analysed the webpage and following is what happens:
General

Response Headers

  • HTTP/1.0 200 OK
  • Content-Length: 52
  • Content-Type: text/plain

Request Headers
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3

  • Accept-Encoding: gzip, deflate
  • Accept-Language: en,nl;q=0.9,nl-NL;q=0.8,en-US;q=0.7
  • Cache-Control: max-age=0
  • Connection: keep-alive
  • Host: 10.10.10.50
  • Upgrade-Insecure-Requests: 1
  • User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36

When I try the same in GET mode with NodeRed and HTTP request node I only receive an empty string:
msg.payload: string[0]
" "
when I try "the" example, simply replacing the URL with https://nodered.org I get a perfect outcome.

can you try with curl or wget ?
maybe you need to add msg.headers object to match those sent by the browser ?

I thought it would be simple, but apparently it isn't.
I can use curl or wget if that would solve the issue, but first I would need to study how it works for sure :wink:

I tried wget on the console, and it is returning (downloading) the outcome.
When I do the same in NodeRed (using an exec node), I get the same effect: a download.
So that seems to work, but I can't capture the outcome that way of course.

Alright... curl is also a system command... so in the exec node I entered te curl and now I have a payload. Thanks!

I think @dceejay was trying to determine if it worked with curl, you can inspect the headers.

Note that you should set the debug node to "complete msg object" as the headers are not in the payload.

Hi Dirk,
Some time ago I have developed the node-red-contrib-http-logger node to see what is being send (e.g. by the http-request node). So then you can compare it with the request that your browser sends (which you can see in the 'Network' tabsheet of your browser's developer tools).
But curl could indeed be sufficient.
Bart

2 Likes