Can't get HTTP binding to work with API


I’m trying to get the HTTP Binding to work with my custom API, but it just won’t work.

Here’s a sample from my API:

    "price_yesterday":  "0.582",
    "name":             "Tirol",
    "price_today":      "0.582",
    "price_difference": "0.0",
    "id":               "tirol"

Here’s the item definition and the transformation file:

Number Heizung_Oelpreis "Ölpreis [%.3f €/l]" <oil> {http="<[]"}

(function(i) {

  var results = JSON.parse(i),
      i       = results.length

  while (--i && results[i]["id"] != "tirol") {}

  return results[i]["price_today"]


It’s throwing this error:

2016-02-17 07:18:43.446 [ERROR] [.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service
java.util.UnknownFormatConversionException: Conversion = '2'
	at java.util.Formatter.checkText( ~[na:1.8.0_66]
	at java.util.Formatter.parse( ~[na:1.8.0_66]
	at java.util.Formatter.format( ~[na:1.8.0_66]
	at java.util.Formatter.format( ~[na:1.8.0_66]
	at java.lang.String.format( ~[na:1.8.0_66]
	at org.openhab.binding.http.internal.HttpBinding.execute( ~[na:na]
	at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute( ~[na:na]
	at org.openhab.core.service.AbstractActiveService$ ~[na:na]

Have you tried using JSONPATH instead of JS?

I have just learned about JSONPATH today.

The JSONPATH syntax seems to be right but it’s still showing the same error, so the transformation doesn’t seem to be the issue.

Number Heizung_Oelpreis "Ölpreis [%.3f €/l]" <oil> {http="<[$[?('tirol')].price_today)]"}

As a first step, you could try JSONPATH with a string Item, so you can see, what’s the result of the transformation.

Ok, I finally got it working.

First of all, I had to use an external shell script with curl to even get a response, the HTTP binding wouldn’t work, neither would an inline EXEC curl.

The second problem was that my API was showing the numbers as strings, which I fixed.

Lastly, the JSONPATH above returned an array, which is strange, but I simple added a [0] to retrieve the value:


But does anyone know why neither the HTTP nor the EXEC binding are able to fetch an URL which is perfectly valid like this:

Is there anything in this URL that has to be escaped?

Ok, so I tried setting this up as a cached item in the http binding like this:


And it throws this error:

2016-02-21 18:18:42.158 [ERROR] [] - Fatal transport error: PKIX path building failed: unable to find valid certification path to requested target
2016-02-21 18:18:42.158 [ERROR] [.o.b.http.internal.HttpBinding] - No response received from 'oilprice'

So it seems to be an SSL error, what could the cause of this be?

Java and may not share a common certificate authority:

These instructions might help in this situation.

Thank you, this fixed it!

I’ll leave this here for future reference (note: /usr/libexec/java_home is OS X specific):

#!/usr/bin/env sh

export JAVA_HOME="$(/usr/libexec/java_home)"


curl -sL "" -o "${CERT}"

"${JAVA_HOME}/bin/keytool" -import -trustcacerts -noprompt -keystore "${JAVA_HOME}/jre/lib/security/cacerts" \
  -alias StartCom-Root-CA -storepass changeit -file "${CERT}"
1 Like