Http-binding inhibit by ecma rule

i configured the http binding (on openhab 3.2) for requesting some states from my oven in the kitchen every 30 sconds to get some states from the oven into openhab.
this works fine.

but - if the oven is not running then i got out that on every request some relays are clicking. So i would stop requests if the oven is not running.

is there any way to enable disable the requests which is http bindung sending to the device by an ecma rule? i tried to do it but got no successful way. my installation is a containerinstallation and from that i dont want to modify installation by removing jar files with rules as i read in another thread.
Is there an efficient way for it?

Maybe enable/disable the thing via /things/{thingUID}/enable in the REST API?

i tried the following code with “false” in the last line and it was possible to disable the thing:

var HTTP=Java.type("org.openhab.core.model.script.actions.HTTP");

var url = "";
var headers = [];
headers["Authorization"] = "Bearer oh.admintoken.geheim";

var returnvalue = HTTP.sendHttpPutRequest(url, 'true', "application/json",headers, 2000)

but with true it was never possible to reenable. result seems to be “HTTP 415 Unsupported Media Type”

any idea?

use “text/plain” instead of “application/json”

Hi Wolfgang,

thanks. your were right. But i also had to change the order “text/plain”,‘true’

var returnvalue = HTTP.sendHttpPutRequest(url, "text/plain",'true',headers, 2000)

Now it works fine. Tank you!