Basic auth format for http binding

I am trying to change settings in my camera using its web api. I know the api call is correct however I am having trouble doing the authentication. I have tried several formats and done enough googling to feel ok posting here.

Here is the api call with a phony username (admin) and password (qwerty).

The documentation for the api says it supports both basic and digest auth. When using basic auth it requires the username and password to be base64 encoded.

Any suggestions?

I have wondered if this will have to be a script like the examples:


Have you tried encoding the username and password in Base 64? There is an online encoder/decoder here.

I did however it didn’t like the syntax.


So it worked but you didn’t like how the url looked?

If that is the case I think you will need to figure out some other way to communicate with the device. I think openHAB only supports basic authentication and per your posting above the basic authentication requires base 64 encoding.

I dont know what was different last night but I couldnt get the formated url to work in wget or a browser but now it is working in the browser using basic auth. However it is still not working in the binding.

Switch OfficeCameraMotion “Office Camera Motion” { http=">[ON:POST:http://admin:qwerty@[0].Enable=true] >[OFF:POST:http://admin:qwerty@[0].Enable=false]" }

I have enabled debugging for the http binding but it doesnt give me any additional information.

Do I need to escape any of those characters?

Even setting the binding to trace doesnt produce any logs for the http binding.

You should see something, even if it is just one log statement near the start of openHAB saying the HTTP binding is loaded and running. If you don’t see that then the binding itself may not be installed. Verify that the HTTP binding’s jar file is in your addons folder.

Well I do see the http binding starting but thats it.

I think the problem might be the URL. It doesnt work in curl. It will work in the browser though[0].Enable=false

Curl doesn’t like the brackets or & symbol. I have tried replacing them with the ascii couter parts however that hasnt worked either.


Thanks for the help.

By replacing them with the ascii counter parts do you mean the escaped URL encodings:

&    %26
[     %5B
]     %5D


Your browser will do this for you but curl and openHAB will not.

Ok I finally found a curl command that works. As such I have switched from trying to do an http binding to an exec binding. I kept trying different options and this finally worked

curl --basic --user admin:1qaz3edc5tgb7ujm\[0\].Enable=true

So then I tried several variations of:

Switch OfficeCameraMotion “Office Camera Motion” { exec=
“ON:‘curl --basic --user admin:qwerty\[0\].Enable=true’,
OFF:‘curl --basic --user admin:qwerty\[0\].Enable=false’” }

Error: 23:17:23.553 ERROR o.o.m.i.i.GenericItemProvider[:354]- Binding configuration of type ‘exec’ of item âOfficeCameraMotionâ could not be parsed correctly.
java.lang.NullPointerException: null
at java.util.regex.Matcher.getTextLength(
at java.util.regex.Matcher.reset(
at java.util.regex.Matcher.(
at java.util.regex.Pattern.matcher(
at org.openhab.binding.exec.internal.ExecGenericBindingProvider.processBindingConfiguration(

Am I going to have to escape every special symbol again?

curl\ --basic\ --user\ admin:1qaz3edc5tgb7ujm\\&MotionDetect\\[0\\].Enable=true


Probably. It is the first thing I would try.

If that doesn’t work, put your curl into a script and execute it that way.

Also, per the doc on the wiki for the exec binding, use "@@"for your spaces instead of "\ " or " ".

I feel like I had to go the round about way of doing it three times.
I ended up making a bash script with the one line to run the curl script, which was called by the exec binding. I had expected to just be able to use the http binding. I guess things are rarely as easy as we expect them to be.

Thanks for all the help guys.