HTTP Binding 3.4.0 vs 4.2.0

Hi all,
I had a script running in 3.4 without any issues:

var url = "https://user:password@url/api/call/status";
var inputJSON = actions.HTTP.sendHttpGetRequest(url);

but with my new 4.2. instance that does not work anymore and gives me following error message:

 Fatal transport error: java.util.concurrent.ExecutionException: java.net.UnknownHostException: url: Name or service not known

Any ideas?

try

var url = "https://user:password@url/api/call/status"
var inputJSON = sendHttpGetRequest(url,5000)

just without actions.HTTP.
the number is a timeoutvalue but its not necessary…
Greets

Thank you for your response, unfortunately I get following log:
I have a textbased JS rule, implemented by the rule builder (rules.JSRule({…}))
Do I need to import some library?

 ReferenceError: "sendHttpGetRequest" is not defined: ReferenceError: "sendHttpGetRequest" is not defined

Basically, I call the requests in my JS rules the same way as you.
Since passing username and password in the URL is generally not recommended, I would try passing them in the header using Basic authentication.

HTTP.sendHttpGetRequest(String url, Map<String, String> headers, int timeout)

Example:

var header = new Map();
    header.set("Authorization", "username:password");
    header.set("Accept", "application/json");
    ...

If special characters are included in the username or password you must Base64 encode “username:password”

Kind regards

@uk59821 might be on the right track here. Using basic auth the way you are has been deprectated and considered bad practice for quite some years. It might be the case that Java 17 no longer supports that.

I’m all but certain there has been nothing done in OH itself that impacts this and the exception is comming from the underlying Java library, not OH in this case.

@Baschtlwaschtl I think it assuming Rules DSL. The code as shown could be either so it’s an understandable mistake. Please always mention what langauge you are using when posting code fragments unless it’s absolutely positively obvious what language it is

But the short of it is you do need the actions.HTTP in JS.

1 Like

Yes, I thought it was RulesDSL..
sorry.

It was another issue not related to openhab.
My local DNS was not working correctly for the openhab instance.