Node-RED with http request from local Serverpage

Hello there,
i have a problem to get some data from my local Webserver with http request in node-red.
This is my local Webserver, where i can see some values from my photovoltaics

zever

Now i tried to geht the Value "Pac(W)" and "E_today(KWh)" with http request into node-red

But with an simple injekt --> http request --> debug i will get an StatusCode400 response.

What did i wrong?

Export the flow (the inject and http request) and paste it here so we can see what you have done. See this post for how to include a flow in a post : How to share code or flow json

This i the flow i created

A 400 response means the server didn't like your request for some reason. But it hasn't returned a message in the payload to give any indication what the problem may be.

Is it a page you log into locally? Or can you normally just open it in your browser?

It may be checking for certain http headers to be present - such as the user agent string. At this point I would use the browser developer tools to take a closer look at the request when made from the browser and see what headers you may need to set in you http request (via msg.headers)

Hi knolleary,
thanks a lot for your fast response.
I is a Page, i can connect with http://192.168.178.40
There is no login or password needed.

What can i do to test?

@Collin in the next post there is my flow.

[
    {
        "id": "5659ece5.eed734",
        "type": "debug",
        "z": "fa00c677.24d718",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "x": 750,
        "y": 740,
        "wires": []
    },
    {
        "id": "999b1b3d.03ec08",
        "type": "inject",
        "z": "fa00c677.24d718",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 280,
        "y": 740,
        "wires": [
            [
                "4bfd02f1.0d94dc"
            ]
        ]
    },
    {
        "id": "4bfd02f1.0d94dc",
        "type": "http request",
        "z": "fa00c677.24d718",
        "name": "",
        "method": "GET",
        "ret": "txt",
        "url": "http://192.168.178.40/",
        "tls": "",
        "x": 490,
        "y": 740,
        "wires": [
            [
                "5659ece5.eed734"
            ]
        ]
    },
    {
        "id": "2d7d1173.c1aa9e",
        "type": "comment",
        "z": "fa00c677.24d718",
        "name": "http://192.168.178.40/",
        "info": "",
        "x": 520,
        "y": 660,
        "wires": []
    },
    {
        "id": "68559ee0.5231a",
        "type": "comment",
        "z": "fa00c677.24d718",
        "name": "GET",
        "info": "",
        "x": 470,
        "y": 620,
        "wires": []
    },
    {
        "id": "37e866f4.d20aaa",
        "type": "comment",
        "z": "fa00c677.24d718",
        "name": "UTF-8",
        "info": "",
        "x": 470,
        "y": 700,
        "wires": []
    }
]

Here's what I suggested in my previous reply:

Thank you, but i did not realy understand what to do.
Maybe it´s because of my bad technical english, or because i´m new to nodered.
I tried to open the Page (192.168.178.40) with Chrome Browser and Developer Tools.
This works.
But how can i see any errors in nodered?

In addition to @knolleary's suggestions, are you running the browser on the same machine that is running node-RED?
If not then open a terminal on the machine running node-RED and run
wget http://192.168.178.40
and make sure that works ok.

The message returned by the HTTP Request node already contains all the information the server has returned. You can see the payload is empty - so the server has not provided any error messages to help. All you have is a 400 status code from the server.

Using the browser development tools you can inspect the request the browser makes and look at the Headers it sends with the request. The server may be expecting one of those headers to be set properly for the request to work,

This is all just guess work - as it isn't a public server we can look at ourselves, we can't debug this for you.

1 Like

@ Colin, the NodeRed is running on my Ubuntu Server.
I tried there "wget http://192.168.178.40" and it works.
The page will be downloaded

@knolleary do you have TeamViewer?

That is surprising, as I would have thought that using wget would be pretty much the same as running the http node. In a terminal run

node-red-stop
node-red-start

and paste the result here. Starting from the Welcome to node red message.
If those commands do not work then stop and restart node red however you normally do it and post the result. That will let us check which versions of tools you are using.

|node-red.0|2019-01-04 17:16:38.495|info|Starting node-red: --max-old-space-size=128 /opt/iobroker/node_modules/node-red/red.js -v --settings /opt/iobroker/iobroker-data/node-red/settings.js|
|---|---|---|---|
|node-red.0|2019-01-04 17:16:36.937|info|starting. Version 1.7.1 in /opt/iobroker/node_modules/iobroker.node-red, node: v8.14.0|
|host.rock64|2019-01-04 17:16:34.986|info|instance system.adapter.node-red.0 started with pid 6740|
|host.rock64|2019-01-04 17:16:32.434|info|instance system.adapter.node-red.0 terminated with code 0 (OK)|
|host.rock64|2019-01-04 17:16:32.389|info|stopInstance timeout "1000 system.adapter.node-red.0 killing pid 24090|
|node-red.0|2019-01-04 17:16:31.991|info|node-red exited with 0|
|host.rock64|2019-01-04 17:16:31.442|info|stopInstance system.adapter.node-red.0|
|host.rock64|2019-01-04 17:16:31.441|info|object change system.adapter.node-red.0|
|node-red.0|2019-01-04 17:16:31.407|info|kill node-red task|

No.

Try running curl -v http://192.168.178.40 > /dev/null - that will output all of the http request and response headers. Share that with us and we can begin to make specific suggestions on what to try in your flow.

root@rock64:~# curl -v http://192.168.178.40 > /dev/null
* Rebuilt URL to: http://192.168.178.40/
*   Trying 192.168.178.40...
* TCP_NODELAY set
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to 192.168.178.40 (192.168.178.40) port 80 (#0)
> GET / HTTP/1.1
> Host: 192.168.178.40
> User-Agent: curl/7.52.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Connection: close
< Content-Encoding: gzip
< Server: RTCS HTTPSRV/2.5 - Freescale Embedded Web Server v2.5
< Content-Type: text/html
< Cache-Control: max-age=3600
< Content-Length: 2815
<
{ [1259 bytes data]
* Curl_http_done: called premature == 0
100  2815  100  2815    0     0   429k      0 --:--:-- --:--:-- --:--:--  458k
* Closing connection 0
root@rock64:~#
root@rock64:~# wget http://192.168.178.40
--2019-01-04 17:56:08--  http://192.168.178.40/
Connecting to 192.168.178.40:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2815 (2.7K) [text/html]
Saving to: 'index.html'

index.html.1        100%[===================>]   2.75K  --.-KB/s    in 0.002s

2019-01-04 17:56:08 (1.71 MB/s) - 'index.html' saved [2815/2815]

root@rock64:~#

but opening with "cat index.html" shows:

cat

@knolleary - any idea?

Note .1 on the end. I believe that means means that there was already an index.html so it has called this one index.html.1. Delete all such files and try again. You may get the same thing of course.

I guess that means it is a zip file, which seems rather odd.
I also note that in the browser window it has ?l=en on the end, you might play with that.
[Edit]
Having googled I see that means it has compressed it for sending, which is normal. I assume curl and wget would uncompress it, but I may be wrong.

Today i found out, with http://192.168.178.4o i will come automatically to
h**p://192.168.178.4o/home.html

there is an index.html file, but if i try h**p://192.168.178.4o/index.html
they ask for an user and password.
But normaly i don´t need the index.html file because all others (home.html ethernet.html advanced.html and wireless.html are without password.
So i don´t know for what the index.html will be.