REST API no working

I´ve setup a new openhab on raspi 4 as well as a new computer.
unfortunately I´m not able to read api state information. eg:
http://192.168.xxx.xx:8080/rest/items/Wetterstation_1_Temperature is working, but
http://192.168.xxx.xx:8080/rest/items/Wetterstation_1_Temperature/state doesn´t show anything.
If I try this on the openhab api explorer it´s working.
might this be an issue on the browser? working with firefox and edge ist the same result.

Network trace of chrome:

GET /rest/items/AntjesIphone_Online/state HTTP/1.1
Host: pi:8080
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Cookie: X-OPENHAB-SESSIONID=061ebd86-a435-4986-af95-a0aa3a1bf853

Reply:

HTTP/1.1 400 Bad Request
Date: Wed, 26 Jul 2023 08:35:13 GMT
Content-Length: 0
Server: Jetty(9.4.46.v20220331)

Network trace of Firefox:

GET /rest/items/AntjesIphone_Online/state HTTP/1.1
Host: pi:8080
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-US,en;q=0.7,de;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cookie: X-OPENHAB-SESSIONID=ed7d4291-c1de-4415-9dff-3574a9ee9199
Upgrade-Insecure-Requests: 1

Reply:

HTTP/1.1 400 Bad Request
Date: Wed, 26 Jul 2023 08:39:00 GMT
Content-Length: 0
Server: Jetty(9.4.46.v20220331)

The browsers do not send a request as required ( e.g. Accept content type ).
The server / jetty then does not understand the request resp. replies with Bad Request.

Network trace of curl ( curl http://pi:8080/rest/items/AntjesIphone_Online/state )

GET /rest/items/AntjesIphone_Online/state HTTP/1.1
Host: pi:8080
User-Agent: curl/7.68.0
Accept: */*

Reply:

HTTP/1.1 200 OK
Content-Type: text/plain
Date: Wed, 26 Jul 2023 08:43:41 GMT
Content-Length: 2
Server: Jetty(9.4.46.v20220331)
ON

As you can see curl accepts all types including text/plain which is send back by jetty.
You would have to make sure that the browser sends a request for text/plain then it should be possible to get a correct reply from the server.
The other request for the item accepts text/json which is send back and rendered by the browser.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.