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(DSLScriptEngine.java:135) ~[?:?] at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.lambda$0(ScriptActionHandler.java:62) ~[?:?] at java.util.Optional.ifPresent(Optional.java:183) [?:?] at org.openhab.core.automation.module.script.internal.handler.ScriptActionHandler.execute(ScriptActionHandler.java:59) [bundleFile:?] at org.openhab.core.automation.internal.RuleEngineImpl.executeActions(RuleEngineImpl.java:1180) [bundleFile:?] at org.openhab.core.automation.internal.RuleEngineImpl.runRule(RuleEngineImpl.java:988) [bundleFile:?] at org.openhab.core.automation.internal.TriggerHandlerCallbackImpl$TriggerData.run(TriggerHandlerCallbackImpl.java:89) [bundleFile:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?] at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?] at java.lang.Thread.run(Thread.java:829) [?:?]
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:
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,