Issue with JSONPATH from HTTP Binding error code 1010

Dear Community,

I’m kind of a rocket nerd and like to watch launches, so I’m trying to parse the JSON from here:
https://launchlibrary.net/1.4/launch/next/1

I’ve done this for a while, but recently I’m getting an error and I do not know what changed. I’m on the latest 2.5.x OH.

with the following http.cfg:

http:rocketlaunch.url="https://launchlibrary.net/1.4/launch/next/1"
http:rocketlaunch.updateInterval=3600000

and these items:

String RocketLaunchNextUTC	    "Launch Time UTC [%s]"          <flowpipe>          (gRocketLaunch) {http="<[rocketlaunch:300000:JSONPATH($.launches[0].net)]"}
String RocketLaunchNextMission	    "Mission [%s]"                  <settings>      (gRocketLaunch) {http="<[rocketlaunch:300000:JSONPATH($.launches[0].missions[0].name)]"}
String RocketLaunchNextRocket	    "Launcher [%s]"                 <rocket>        (gRocketLaunch) {http="<[rocketlaunch:300000:JSONPATH($.launches[0].rocket.name)]"}
String RocketLaunchNextPad	    "Pad [%s]"                      <movecontrol>   (gRocketLaunch) {http="<[rocketlaunch:300000:JSONPATH($.launches[0].location.pads[0].name)]"}
String RocketLaunchNextISO          "Launch Time UTC ISO [%s]"      <flowpipe>          (gRocketLaunch) {http="<[rocketlaunch:300000:JSONPATH($.launches[0].isonet)]"}
Number RocketLaunchID	            "ID [%.0f]"                                 (gRocketLaunch) {http="<[rocketlaunch:300000:JSONPATH($.launches[0].id)]"}
Number RocketLaunchTimeEpoch	    "Launch Time Epoch [%.0f]"      <flowpipe>  (gRocketLaunch) {http="<[rocketlaunch:300000:JSONPATH($.launches[0].netstamp)]"}

i’m getting this error:

2020-04-10 17:48:26.245 [WARN ] [ab.binding.http.internal.HttpBinding] - Transformation 'JSONPATH($.launches[0].location.pads[0].name)' threw an exception. [response=error code: 1010]

org.openhab.core.transform.TransformationException: Invalid path '$.launches[0].location.pads[0].name' in 'error code: 1010'

	at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:71) ~[bundleFile:?]

	at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:218) [bundleFile:?]

	at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:146) [bundleFile:?]

	at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169) [bundleFile:?]

2020-04-10 17:48:26.255 [WARN ] [ab.binding.http.internal.HttpBinding] - Transformation 'JSONPATH($.launches[0].missions[0].name)' threw an exception. [response=error code: 1010]

org.openhab.core.transform.TransformationException: Invalid path '$.launches[0].missions[0].name' in 'error code: 1010'

	at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:71) ~[bundleFile:?]

	at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:218) [bundleFile:?]

	at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:146) [bundleFile:?]

	at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169) [bundleFile:?]

2020-04-10 17:48:26.267 [WARN ] [ab.binding.http.internal.HttpBinding] - Transformation 'JSONPATH($.launches[0].isonet)' threw an exception. [response=error code: 1010]

org.openhab.core.transform.TransformationException: Invalid path '$.launches[0].isonet' in 'error code: 1010'

	at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:71) ~[bundleFile:?]

	at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:218) [bundleFile:?]

	at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:146) [bundleFile:?]

	at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169) [bundleFile:?]

2020-04-10 17:48:26.278 [WARN ] [ab.binding.http.internal.HttpBinding] - Transformation 'JSONPATH($.launches[0].rocket.name)' threw an exception. [response=error code: 1010]

org.openhab.core.transform.TransformationException: Invalid path '$.launches[0].rocket.name' in 'error code: 1010'

	at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:71) ~[bundleFile:?]

	at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:218) [bundleFile:?]

	at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:146) [bundleFile:?]

	at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169) [bundleFile:?]

2020-04-10 17:48:26.289 [WARN ] [ab.binding.http.internal.HttpBinding] - Transformation 'JSONPATH($.launches[0].net)' threw an exception. [response=error code: 1010]

org.openhab.core.transform.TransformationException: Invalid path '$.launches[0].net' in 'error code: 1010'

	at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:71) ~[bundleFile:?]

	at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:218) [bundleFile:?]

	at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:146) [bundleFile:?]

	at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169) [bundleFile:?]

2020-04-10 17:48:33.329 [WARN ] [ab.binding.http.internal.HttpBinding] - Transformation 'JSONPATH($.launches[0].netstamp)' threw an exception. [response=error code: 1010]

org.openhab.core.transform.TransformationException: Invalid path '$.launches[0].netstamp' in 'error code: 1010'

	at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:71) ~[bundleFile:?]

	at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:218) [bundleFile:?]

	at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:146) [bundleFile:?]

	at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169) [bundleFile:?]

2020-04-10 17:48:33.339 [WARN ] [ab.binding.http.internal.HttpBinding] - Transformation 'JSONPATH($.launches[0].id)' threw an exception. [response=error code: 1010]

org.openhab.core.transform.TransformationException: Invalid path '$.launches[0].id' in 'error code: 1010'

	at org.openhab.core.transform.TransformationHelper$TransformationServiceDelegate.transform(TransformationHelper.java:71) ~[bundleFile:?]

	at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:218) [bundleFile:?]

	at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:146) [bundleFile:?]

	at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169) [bundleFile:?]

I’ve triple-checked the JSONPATH and it is correct. Using also different JSONPATHs so I think I know what I’m doing.
Maybe something is wrong with the pipe | symbol which is in the .name ?

Any help is greatly appreciated!

Try this, and see what’s in it

String DiagnosticRawReturn	    "Raw data from LaunchLibrary [%s]"  {http="<[rocketlaunch:300000:default"}

This is flooding the logs with:


2020-04-10 18:12:40.972 [ERROR] [b.core.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service

java.lang.IllegalArgumentException: given transformation function 'default' does not follow the expected pattern '<function>(<pattern>)'

	at org.openhab.binding.http.internal.HttpBinding.splitTransformationConfig(HttpBinding.java:261) ~[?:?]

	at org.openhab.binding.http.internal.HttpBinding.execute(HttpBinding.java:211) ~[?:?]

	at org.openhab.core.binding.AbstractActiveBinding$BindingActiveService.execute(AbstractActiveBinding.java:146) ~[bundleFile:?]

	at org.openhab.core.service.AbstractActiveService$RefreshThread.run(AbstractActiveService.java:169) [bundleFile:?]

2020-04-10 18:12:41.990 [ERROR] [b.core.service.AbstractActiveService] - Error while executing background thread HTTP Refresh Service

java.lang.IllegalArgumentException: given transformation function 'default' does not follow the expected pattern '<function>(<pattern>)'

	at org.openhab.binding.http.internal.HttpBinding.splitTransformationConfig(HttpBinding.java:261) ~[?:?]

Oh, I thought default worked for inbound. We just want a no-op transform

String DiagnosticRawReturn “Raw data from LaunchLibrary [%s]” {http="<[rocketlaunch:300000:REGEX((.*))"}

My point is that I think you are getting a return, not an error, from the HTTP binding. Something is going wrong after the HTTP request has been sent.

Hmm…

2020-04-10 18:26:04.412 [vent.ItemStateChangedEvent] - DiagnosticRawReturn changed from NULL to error code: 1010

I’ve tried other HTTP requests to that site with very specific content, but I always get Error code 1010. Unfortunately I do not know what this error means.

Maybe there is an issue with the website.

I can access is through Firefox just fine and see the JSON content.

Me neither. I’d be fairly confident it comes from the remote site.

Try as http instead of https ?

Try some other web service, to eliminate some firewall issue etc. at your end.

Also no luck with http.

Could it be connected to this:

I’m using a pihole since recently. So Not sure if that makes a difference. But I can still access that API with my regular browser from my PC (and they all go through the pi-hole).

1 Like

Yep. They’re filtering out non-browser access based on the user-agent field or some related combination of headers.

Is there any way to circumvent this?

I don’t think http binding has a way to override the User-Agent http header.

Also, this feature recently was added to sendHttpGetRequest, but it won’t be available until 3.0.

sendHttpGetRequest(String url, Map<String, String> headers, int timeout)

The only way I can think to do this is using curl in a shell script. But, first you’d need to figure out which http header (or headers) they’re filtering on.

Others may better ideas.

1 Like

There is a way to get it now for 2.5.x. An updated core jar is available in this post. It works for me for an added header. I don’t know if it can help the problem in this thread or not.

I believe it’s unrelated to the http-binding (v1 addon).

However, from the http binding doc, it seems possible to add http headers: