Rules with sendHttpPutRequest and AuthToken

Dear Community,

In my approach of creating a rule in OpenHAB 3.2.0 where I need to send a HTTP Put Request to the OpenHAB REST API, I failed to configure sendHttpPutRequest correctly so that the Authentication Token required to access to the OpenHAB REST API is properly handed over.

I tried the following Rules DSL code:

sendHttpPutRequest("http://<MyAuthToken>:@localhost:8080/rest/things/knx%3Aip%3Arouter/enable", "application/json", "false")

However, the result is:

2022-03-18 00:28:25.037 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'knx-1' failed: Index 1 out of bounds for length 1 in knx
javax.script.ScriptException: Index 1 out of bounds for length 1 in knx
	at org.openhab.core.model.script.runtime.internal.engine.DSLScriptEngine.eval( ~[?:?]
	at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.lambda$0( ~[?:?]
	at java.util.Optional.ifPresent( [?:?]
	at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.execute( [bundleFile:?]
	at org.openhab.core.automation.internal.RuleEngineImpl.executeActions( [bundleFile:?]
	at org.openhab.core.automation.internal.RuleEngineImpl.runRule( [bundleFile:?]
	at org.openhab.core.automation.internal.TriggerHandlerCallbackImpl$ [bundleFile:?]
	at java.util.concurrent.Executors$ [?:?]
	at [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker( [?:?]
	at java.util.concurrent.ThreadPoolExecutor$ [?:?]
	at [?:?]

Worth to note, the API Explorer in OpenHAB correctly processes my request. So I know the API call as such works, but I fail to correctly code it.

I started from the example given here:

When searching the forum for various different solutions I found the Auth Token placed into a separate header field. I also found solutions not based on Rules DSL, but rather on JavaScript. However, I have Ivan’s Helper Libraries installed with the Python setup, so I was not sure whether JavaScript will work at all in my environment.

In other words, I got lost with all these various options. Does anybody have a hint for me as how to further proceed?

Thanks a lot,

Another try in Rules DSL failed:

val headers = newHashMap("Authorization" -> "Bearer <MyAuthToken>", "WWW-Authenticate" -> "Basic")
sendHttpPutRequest("http://localhost:8080/rest/things/knx%3Aip%3Arouter/enable", "application/json", 'false', headers, 10000)

In this case, I receive:

2022-03-18 15:28:37.016 [WARN ] [s.impl.WebApplicationExceptionMapper] - HTTP 415 Unsupported Media Type

This approach was based on:

According to the REST API description
it needs to be "text/plain"
instead of

Yep. application/json worked up until 3.1, but stopped working in 3.2. It perhaps always should have been text/plain in the first place.