Hello.
I need some help to get nodered with openhab2 up and running
I have a very basic flow:
Bigtimer -> Openhab OUT
When the event is triggered i get the following error:
"response error '{"statusCode":400,"body":"<html>\n<head>\n<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\"/>\n<title>Error 400 Bad Request</title>\n</head>\n<body><h2>HTTP ERROR 400</h2>\n<p>Problem accessing /rest/items/gXmasLights. Reason:\n<pre> Bad Request</pre></p><hr><a href=\"http://eclipse.org/jetty\">Powered by Jetty:// 9.4.20.v20190813</a><hr/>\n\n</body>\n</html>\n","headers":{"connection":"close","cache-control":"must-revalidate,no-cache,no-store","content-type":"text/html;charset=iso-8859-1","content-length":"343","server":"Jetty(9.4.20.v20190813)"},"request":{"uri":{"protocol":"http:","slashes":true,"auth":null,"host":"localhost:8080","port":"8080","hostname":"localhost","hash":null,"search":null,"query":null,"pathname":"/rest/items/gXmasLights","path":"/rest/items/gXmasLights","href":"http://localhost:8080/rest/items/gXmasLights"},"method":"POST","headers":{"content-length":1}}}' on 'http://localhost:8080/rest/items/gXmasLights'"
sind a GET to this URL (http://localhost:8080/rest/items/gXmasLights) gives me the correct item. A POST the error message you ca see in the codeblock.
Any idea, what i have configured wrong?
Here the openhab2-out item (which imho causes the trouble):
@Bruce_Osborne
yep, or a bad requests dropps also, when POSTing with an empty body against the rest endpoint.
Problem is: I don’t know where to continue to debug
@Wolfgang_S
after your suggestion i tried changing the ON/OFF Text in the bigTimer node. Same error as before.
Can you run a network sniffer so that we can check the exact content of the request that is being sent to the REST API ?
The request that is being described in the error message does not show the content-type of the request which needs to be text/plain.
I assume since the Item starts with g it is a Group. Is the Group specified as a type of Switch? There are a couple of variants documented in the official documentation for this.
2020-12-20 17:36:20.979 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/gXmasLights' with an invalid status value '1'.
2020-12-20 17:37:21.057 [WARN ] [rest.core.internal.item.ItemResource] - Received HTTP POST request at 'items/gXmasLights' with an invalid status value '1'.
seems okay imho? The group itself works fine via ui and alexa.
BUT your very first assumption was correct: it was an issue on the rednode side.
So in case someone stumbles over the same problem:
It was a simple error: ON msg (which text box is described as “mqtt msg” does NOT refer to mqtt only, but to every output. ON text is just a simple ui text message in node red and has nothing to do with the actual nessage send to openhab.
long story short: write ON and OFF in the mqqt payload field and everything is fine.
the “1” send as payload was a debugging error on my side