openhab / openhab1-addons

Add-ons for openHAB 1.x
Eclipse Public License 2.0
3.43k stars 1.71k forks source link

[HTTP] Support PUT/PATCH with request body #5845

Open simonihmig opened 5 years ago

simonihmig commented 5 years ago

Expected Behavior

http=">[<command>:PUT:<url>:<bodycontent>]" should send a PUT request with <bodycontent> as the HTTP body.

Current Behavior

Sending a HTTP body is constrained to POST requests only, hardcoded here: https://github.com/openhab/openhab1-addons/blob/master/bundles/binding/org.openhab.binding.http/src/main/java/org/openhab/binding/http/internal/HttpBinding.java#L279

Possible Solution

Support PUT and PATCH requests in the same way as POST.

Context

In a RESTful API, sending a POST means creating a resource, which you rarely would want to do in a binding. Usually you would update a resource (i.e. change its state), which is represented by a PUT or PATCH request, with the HTTP body containing the data to be changed (e.g. JSON). So this would a common use case for a binding, but is currently not supported.

kohlsalem commented 4 years ago

Here https://community.openhab.org/t/http-binding-for-homepilot-wrong/81669/5 i found the same issue. In my cuase PUT is mandatory. It would be nice, if somebody could have a look and fix that; does not look impossible to people having the IDE set up....

I havily dislike to work around this with rules; I offer a bug bounty in form of a PIZZA as a little thanks for the one who would look after that....

(== i order it to you or Paypal 10€)

5iver commented 4 years ago

There is work being done on a 2.x version of the binding, so you may want to request this feature there. Though it may be included already.

https://github.com/openhab/openhab2-addons/pull/4342