HTTP Get request and get reponse

Hi,
into a rule I need to perform and HTTP GET and get response into a variable.
The remote HTTP reply with some json and i need to use it into this rule.
It is possible to perform an HTTP Get request and get the result into a String Variable?

Thanks

var String value = sendHttpGetRequest("url")
1 Like

you have to use the HTTP-binding for this:

  1. using it as an item, which gets periodically updated (if it is just Information you Need)
    https://docs.openhab.org/addons/bindings/http1/readme.html#handling-json
  2. using it as an Action within a rule to trigger an Action or a realtime-information https://docs.openhab.org/addons/actions.html#http-actions

in both cases, you can transform the JSON into the string you’ll Need via simple JSONPATH Transformation:
https://docs.openhab.org/addons/transformations/jsonpath/readme.html

1 Like

Thanks,
it work fine,
Marco