Restful - set value via http link...not working anymore

Hi,
i used to set values in OH1.83 long time ago via http link (restful). did switch to MQTT and never had a usecase anymore. Now i tried again with 2.3dev but seems to not work as before (i know the link changed…but still. tried several variants…). Can anyone tell me what I do wrong…RestAPI “modul” is installed.

http://192.168.1.11:8080/rest/items/SmartDisplay01vcc=22 (also tried “22”).

Result:

error
message “HTTP 404 Not Found”
http-code 404
exception
class “javax.ws.rs.NotFoundException”
message “HTTP 404 Not Found”
localized-message “HTTP 404 Not Found”

If you have the ClassicUI installed, the CMD servlet is still available in OH2… http://192.168.1.11:8080/classicui/CMD?SmartDisplay01vcc=22

This is different than the REST API. If you have the REST API documentation installed, you can access it through the dashboard, or directly at http://192.168.1.11:8080/doc/index.html.

If you want to use the REST API, the command (i.e. 22) needs to be the payload to a POST method.

Using curl, it would be something like this.

curl -X POST --header "Content-Type: text/plain" --header "Accept: application/json" -d "22" "http://192.168.1.11:8080/rest/items/SmartDisplay01vcc"

hm, thanks - you’re right …CMD still works fine. Did not even try as i generally mixed up Restful and http.
curl works - but (i know boarder to what people here may be able to answer) any ideas what this ESP8266 library may need to get in terms of command?

My assumption is that I need POST not PUT.
so looking and the library doc:

post(const char* path, const char* body)
post(const char* path, String* response)
post(const char* path, const char* body, String* response)

String response = "";
int statusCode = client.post("/", &response);
statusCode = client.post("/", "foo=bar");
response = "";
statusCode = client.post("/", "foo=bar", &response);

Which ment for me:

int statusCode = client.post("/rest/items/SmartDisplay01vcc", "55");

(as I ignore the response, maybe a mistake - also btw GET works fine…so i guess the overall setup is fine like wifi link and ip adress+port)

Would be great if someone could has experience and some ideas what else could be wrong on my side.

Thanks a lot,
Norbert

Just fixed my problem, in case someone else runs into this issue. I used the GET procedure with ESP and restclient library long time and worked like a charm. Now wanted to also POST item values from ESP to Openhab which did not work out as expected.

What helped, was to add the content-type setting (client.setContentType(“text/plain”);). This was not required for GET, but for POST@Openhab this was required. Now all works fine.