HTTP Binding - No JSON returned?

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:

curl --request GET --get “” --header “Authorization: Bearer API_KEY” --header “Content-Type: application/json” --header “Accept: application/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:

UID: http:url:2adbbe1589
label: GivEnergy API
thingTypeUID: http:url
authMode: BASIC
- headers=“Authorization=Bearer
ignoreSSLErrors: false
delay: 0
stateMethod: GET
refresh: 10
commandMethod: GET
timeout: 3000
bufferSize: 2048

  • id: SBP
    channelTypeUID: http:string
    label: SBP
    description: “”
    configuration: {}

All the Channel Item returns is this, and not the expected JSON in a String:


What am I doing wrong here? Any help from the community would be really appreciated.


Uploaded a screenshot as I couldn’t paste the String Channel result.

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

--header “Content-Type: application/json” --header “Accept: application/json”

Or maybe it’s your api key including any special characters that needs to be escaped or is there a copy/paste issue, e.g. with ’ vs `

I have tried with the missing headers, but same result. I haven’t tried the escaping, so will try that next and get back to you.


@Matze0211 I think you might be on to something, here’s my code with the Headers now:

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?

Thanks again,

The syntax of the headers send to be wrong
According to documentation it should be

    - key1=value1
    - key2=value2
    - key3=value3

Therefore you would need

    - "Authorization=Bearer API key"
    - "Content-Type=application/json"

@Matze0211 That fixed it, thank you so much!

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:

Thanks again for your help and quick response.


1 Like