Newbie to openHAB. Got most of my home setup for automation, loving it.
Having real trouble getting a simple HTTP Binding to work. I can run the following Curl fine from my Raspberry Pi running openHAB (SSH session). It returns the expected JSON:
I’ve setup the Thing using the HTTP Binding, and tried to create a String Channel so I can see the output coming back as I’m expecting JSON which I can then switch to a Number Channel and do some JSON Transformation on. I could only get NULL when trying to use a Number Channel which is what I want. I’m trying to get my Solar Battery percentage. Thing is setup like this:
Obviously the http request is in general working but the other server is returning an error. Based on the html code in your screenshot this looks like the login page.
Maybe the authMode basic and your header are conflicting
Thanks for the response. I have to provide the Auth Bearer Header as it’s an authenticated URL. The Binding selects Basic by default which is correct for the API. I have tried the others and they don’t work as you would expect.
The Curl command works fine with the same Headers so not sure what’s different with the HTTP Binding?
In the curl you have an additional header not configured in the binding. The content type is defined in both versions, but the accept header is missing
You’ll see my API Key is split across 2 lines, but the actual API Key is in black rather than red like the rest of the Header (and the others) - I’m assuming this means this Header is not being passed correctly?
How exactly can I escape the “Authorization=Bearer API_KEY” Header here?
I’m now able to get the correct JSON returned, so it was definitely the API Key not being passed correctly in the YAML. In case this helps anyone else, here’s my final code: