Send httpgetrequest with credentials

Hello, I’m not able to issue a correct httpgetrequest within a rule and proper authentication. My password contains a special character and I’ve read that the https://username:password@url is a deprecated way of doing so. So I encoded it in base64 and use now…

var String json = sendHttpGetRequest(“https://smyurl/mypath{Authorization=Basic myBase64encodedusernameandpassword}”)

which results in openhab having problems with the {} as it says
[ERROR] [ntime.internal.engine.ExecuteRuleJob] - Error during the execution of rule ‘request data from XXX rule’: Illegal character in path at index 73:

Thank you for your help in advance

What are you sending the request to? Which binding and is it a v1 or v2 binding?

That is an action, built in to openHAB (not a binding).

I would think url encoding is needed here, %7B and %7D I think?

Is anyone working on that action? I bring this up as I have added basic and digest authorisation methods to the Ipcamera Binding and it should be easy to transfer what I have learnt across and extend the action to do them in a more user friendly way without needing to create manual hash strings.

1 Like

I am not using and bindings or actions (apart that I don’t know any action associated to http).
In my rule I call

var String json = sendHttpGetRequest('https..........')

the way I use it with cURL which works is
curl -ss -u $credentials https://my-website:port/api/ -X GET -H "Content-Type: application/json"

where $credentials is username:password

sendHttpGetRequest() is an openHAB action.

How did you get on with url encoding the { } ?

EDIT - I stumbled over this

Looks like you need to escape the url encoding e.g. %%7B

Thank you very much for this hint. Unfortunately I now get an “malformed escape pair at index XX:” at the position where I put the %%7b for the curly bracket opening. Any other idea?

Nope, I have nothing else. Did you try %?%7B (as opposed to %%7b)?

Now also tried %?%7B getting the same “Malformed escape pair” error as result :frowning: