I’ve looked far and wide and not finding the answer to this one. In DSL, it is as simple as sendHttpGetRequest(url,timeout).
Doing this in an OpenHab 3 ECMA script generates an error Script execution of rule with UID 'camera_trigger_all' failed: ReferenceError: "sendHttpGetRequest" is not defined in <eval> .
I’m not surprised it needs to be coded a little different. Just can’t find it.
I am using http requests in my ECMA Script rules to send commands to my radio.
For me it works to add the HttpUtil namespace in the rule an then use the executeurl function.
Example:
var HttpUtil = Java.type("org.openhab.core.io.net.http.HttpUtil")
HttpUtil.executeUrl("GET", radioIpAdress + "/main/setVolume?volume=up&step=1", 2000)
Thanks for the code snippet!
Was looking for hours to do the same (pinging healthchecks.io) and did not find any good solution to translate the sendHttpGetRequest to ECMA. With your code it works!
But to come back to the original problem: I don’t see it as very handy to find out the correct namespace before being able to use functions like these.