Cannot send POST request containing item state, variable or received command from OpenHab3 to a remote OpenHab2 instance
items:
Number Cctv_monitorid "CCTV Monitor Id"
Rules:
rule "test rule"
when
Item Cctv_monitorid received command
then
logInfo("Rules", "Received command: [{}]",receivedCommand)
sendHttpPostRequest ("https://user:password@ddns.url/rest/items/Cctv_monitorid", "text/plain", receivedCommand, 10000 )
end
log entry:
[INFO ] [org.openhab.core.model.script.Rules ] - Received command: [1]
[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'cctvevents-1' failed: An error occurred during the script execution: Could not invoke method: org.openhab.core.model.script.actions.HTTP.sendHttpPostRequest(java.lang.String,java.lang.String,java.lang.String,int) on instance: null in cctvevents
- Platform information:
- Hardware: Rpi4 4Gb
- OS: Raspbian GNU/Linux 11 (bullseye)
- Java Runtime Environment: openjdk version “11.0.15” 2022-04-19
- openHAB version: openHAB 3.2.0 Release Build
i’ve already tried this approach:
rule "test rule"
when
Item Cctv_monitorid received command
then
val String url = "https://user:password@ddns.url/rest/items/Cctv_monitorid"
val String header = "text/plain"
var String data = Cctv_monitorid.state
logInfo("Rules", "url: [{}]",url)
logInfo("Rules", "header: [{}]",header)
logInfo("Rules", "data: [{}]",data)
sendHttpPostRequest(url,header,data,20000)
end
with the same result:
[INFO ] [org.openhab.core.model.script.Rules ] - url: [https://user:password@ddns.url/rest/items/Cctv_monitorid]
[INFO ] [org.openhab.core.model.script.Rules ] - header: [text/plain]
[INFO ] [org.openhab.core.model.script.Rules ] - data: [2]
[ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'cctvevents-1' failed: An error occurred during the script execution: Could not invoke method: org.openhab.core.model.script.actions.HTTP.sendHttpPostRequest(java.lang.String,java.lang.String,java.lang.String,int) on instance: null in cctvevents
i’m completely clueless.
also tried using curl executeCommandLine but i’m apparently completely lost with OH3
executeCommandLine("curl", "-X", "POST", "--header", "Content-Type: text/plain", "--header", "Accept: application/json", "-d", Cctv_monitorid.state, "https://user:password@ddns.url/rest/items/Cctv_monitorid")
i could not find anything useful in documentaton, can anyone give me some hints?