Hi,
some context:
I try to create dynamically some manutention alerts (i.e: battery of sensor whatever is empty please replace it, this device need water, (that will then be displayed as switches and be deleted when marked “off”)
What works?
When I use swagger and test the API it works:
It creates the Item properly and return a 201 and I can see the item created.
What doesn’t work?
The problem is when I try to do that through blockly:
It generates some error logs:
2024-11-01 15:32:02.896 [INFO ] [nhab.automation.script.ui.18c5421be6] - Create new item testItem
2024-11-01 15:32:02.897 [INFO ] [nhab.automation.script.ui.18c5421be6] - {
"name": "testItem",
"label": "Todo test item",
"category": "Switch",
"type": "Switch",
"groupNames": [
"ManutentionAlerts"
]
}
2024-11-01 15:32:02.898 [ERROR] [omation.script.javascript.18c5421be6] - Failed to execute script: TypeError: invokeMember (sendHttpPutRequest) on org.openhab.core.model.script.actions.HTTP failed due to: no applicable overload found (overloads: [Method[public static java.lang.String org.openhab.core.model.script.actions.HTTP.sendHttpPutRequest(java.lang.String,int)], Method[public static java.lang.String org.openhab.core.model.script.actions.HTTP.sendHttpPutRequest(java.lang.String,java.lang.String,java.lang.String,int)], Method[public static java.lang.String org.openhab.core.model.script.actions.HTTP.sendHttpPutRequest(java.lang.String,java.lang.String,java.lang.String)], Method[public static java.lang.String org.openhab.core.model.script.actions.HTTP.sendHttpPutRequest(java.lang.String,java.lang.String,java.lang.String,java.util.Map,int)], Method[public static java.lang.String org.openhab.core.model.script.actions.HTTP.sendHttpPutRequest(java.lang.String)]], arguments: [http://192.168.4.167:8087/rest/items/testItem (String), application/json (String), DynamicObject<JSOrdinary>@39a27c96 (DefaultLayout), 3000 (Integer)])
at <js>.:program(<eval>:4)
at org.graalvm.polyglot.Context.eval(Context.java:399)
at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:458)
at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:426)
at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:262)
... 74 more
2024-11-01 15:32:02.898 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '18c5421be6' failed: org.graalvm.polyglot.PolyglotException: TypeError: invokeMember (sendHttpPutRequest) on org.openhab.core.model.script.actions.HTTP failed due to: no applicable overload found (overloads: [Method[public static java.lang.String org.openhab.core.model.script.actions.HTTP.sendHttpPutRequest(java.lang.String,int)], Method[public static java.lang.String org.openhab.core.model.script.actions.HTTP.sendHttpPutRequest(java.lang.String,java.lang.String,java.lang.String,int)], Method[public static java.lang.String org.openhab.core.model.script.actions.HTTP.sendHttpPutRequest(java.lang.String,java.lang.String,java.lang.String)], Method[public static java.lang.String org.openhab.core.model.script.actions.HTTP.sendHttpPutRequest(java.lang.String,java.lang.String,java.lang.String,java.util.Map,int)], Method[public static java.lang.String org.openhab.core.model.script.actions.HTTP.sendHttpPutRequest(java.lang.String)]], arguments: [http://192.168.4.167:8087/rest/items/testItem (String), application/json (String), DynamicObject<JSOrdinary>@39a27c96 (DefaultLayout), 3000 (Integer)])
I don’t really know what is going on here. I use openhab 4.2.2
Also is the bearer token automatically managed? Could that be the cause?
Any help is welcome.