This page last changed on Jan 14, 2014 by voltron43.

I'm trying to implement notifications from OpenRemote using Pushbullet, but I can't seem to get the Http GET command to work properly.

I've followed the Wunderground Weather example and was able to it working, so my setup seems to be okay.

The error I receive is an " ClientProtocolException when executing HTTP method org.apache.http.client.HttpResponseException: Unauthorized".

dev.log output:

2014-01-14 20:41:00,545 DEBUG [HTTP-Thread-8]: Building HttGetCommand
2014-01-14 20:41:00,550 DEBUG [HTTP-Thread-8]: HttpGetCommand: username = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2014-01-14 20:41:00,553 DEBUG [HTTP-Thread-8]: HttpGetCommand: method = GET
2014-01-14 20:41:00,557 DEBUG [HTTP-Thread-8]: HttpGetCommand: url = https://api.pushbullet.com/api/devices
2014-01-14 20:41:01,912 ERROR [HTTP-Thread-8]: ClientProtocolException when executing HTTP method
org.apache.http.client.HttpResponseException: Unauthorized
        at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:67)
        at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:54)
        at org.openremote.controller.protocol.http.HttpGetCommand.requestURL(HttpGetCommand.java:238)
        at org.openremote.controller.protocol.http.HttpGetCommand.send(HttpGetCommand.java:166)
        at org.openremote.controller.service.impl.ControlCommandServiceImpl.trigger(ControlCommandServiceImpl.java:95)
        at org.openremote.controller.rest.ControlCommandRESTServlet.handleRequest(ControlCommandRESTServlet.java:77)
        at org.openremote.controller.rest.RESTAPI.doPost(RESTAPI.java:159)
        at org.openremote.controller.rest.RESTAPI.doGet(RESTAPI.java:112)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.openremote.controller.rest.support.json.JSONCallbackFilter.doFilter(JSONCallbackFilter.java:63)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:354)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:679)
2014-01-14 20:41:01,989 INFO [HTTP-Thread-8]: received message:

My command settings:

Name: Devices
Protocol: HTTP
URL: https://api.pushbullet.com/api/devices
HTTP Method: GET
Username: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The password can be blank because the following curl command works from the commandline:

curl -u XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX: https://api.pushbullet.com/api/devices

The curl command also works for any password.

Am I getting this error because the URL is https?

Note: I'm using the OpenRemote-Controller-2.1.0_FM_ORCJAVA-400 build on a Raspberry Pi with java version:

$ java -version
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1~deb7u1+rpi1)
OpenJDK Zero VM (build 20.0-b12, mixed mode)

Can't help you, as the pushbullet site does not show any information unless I register with them, which I won't
So please tell me a bit more about its API. As you suggest that you got Wunderground working, may I assume that this pushbullet also is an XML-based resource? If so, please give me a sample of the XML, and the elements/attributes you want to retrieve.

For the https see comment here

Posted by pz1 at Jan 14, 2014 21:13
may I assume that this pushbullet also is an XML-based resource? If so, please give me a sample of the XML

The response is in JSON format. However, my "JSONPath Expression" field in my command is blank. Must this be filled out?

My JSON response using curl:

{
    "devices": [
        {
            "extras": {
                "android_version": "4.2.2",
                "app_version": 44,
                "manufacturer": "motorola",
                "model": "XT1049",
                "nickname": "X",
                "sdk_version": "17"
            },
            "id": XXXXXXXXXXXXXXXX,
            "iden": "XXXXXXXXXXXXXXXXXXXXXX"
        },
        {
            "extras": {
                "android_version": null,
                "app_version": 8,
                "manufacturer": "Mozilla",
                "model": "Firefox",
                "nickname": "Work",
                "sdk_version": null
            },
            "id": XXXXXXXXXXXXXXXX,
            "iden": "XXXXXXXXXXXXXXXXXXXXXX"
        },
        {
            "extras": {
                "android_version": null,
                "app_version": 19,
                "manufacturer": "Google",
                "model": "Chrome",
                "nickname": "Glacier",
                "sdk_version": null
            },
            "id": XXXXXXXXXXXXXXXX,
            "iden": "XXXXXXXXXXXXXXXXXXXXXX"
        }
    ],
    "shared_devices": []
and the elements/attributes you want to retrieve

I'd like to retrieve the "id" fields from the response.

For the https see comment here

I came across this comment in my research but can't figure out how to investigate it.

Posted by voltron43 at Jan 15, 2014 05:32

Sorry, I do not know JSON. Hope someone else can answer that

Posted by pz1 at Jan 15, 2014 08:08

Okay, thanks for the effort.

Posted by voltron43 at Jan 15, 2014 08:15

I have recently discovered OpenRemote and had a go at the JSONPath expression yesterday.

In order to retrieve all the id fields from the devices you should use this expression:
$.devices..id

This should return all id's in the devices element.

For more details on the JSONPath: JSONPath details

Posted by tjoek at Jan 15, 2014 08:46

Took a quick look at the source code and for whatever reason, the HTTP protocol implementation expects that a password is provided when a user is.
And if both are not provided, it'll not create an authorization header for the HTTP request.

I have no idea why this decision was made but it basically means that if you can't have an empty password.

So easiest fix for you is: can you define a password on Pushbullet ?

If not, then it means patching the HTTP implementation.

Posted by ebariaux at Jan 15, 2014 08:46
So easiest fix for you is: can you define a password on Pushbullet ?

I tried using a password in a curl command and Pushbullet still gave a good response.

I tried putting the same password into OR and recieved an "Internal Server Error"

dev.log

2014-01-15 20:33:38,959 DEBUG [HTTP-Thread-5]: Building HttGetCommand
2014-01-15 20:33:38,978 DEBUG [HTTP-Thread-5]: HttpGetCommand: username = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
2014-01-15 20:33:38,982 DEBUG [HTTP-Thread-5]: HttpGetCommand: method = GET
2014-01-15 20:33:38,986 DEBUG [HTTP-Thread-5]: HttpGetCommand: password = password
2014-01-15 20:33:38,990 DEBUG [HTTP-Thread-5]: HttpGetCommand: url = https://api.pushbullet.com/api/devices
2014-01-15 20:33:48,524 ERROR [HTTP-Thread-5]: ClientProtocolException when executing HTTP method
org.apache.http.client.HttpResponseException: Internal Server Error
        at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:67)
        at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:54)
        at org.openremote.controller.protocol.http.HttpGetCommand.requestURL(HttpGetCommand.java:238)
        at org.openremote.controller.protocol.http.HttpGetCommand.send(HttpGetCommand.java:166)
        at org.openremote.controller.service.impl.ControlCommandServiceImpl.trigger(ControlCommandServiceImpl.java:95)
        at org.openremote.controller.rest.ControlCommandRESTServlet.handleRequest(ControlCommandRESTServlet.java:77)
        at org.openremote.controller.rest.RESTAPI.doPost(RESTAPI.java:159)
        at org.openremote.controller.rest.RESTAPI.doGet(RESTAPI.java:112)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.openremote.controller.rest.support.json.JSONCallbackFilter.doFilter(JSONCallbackFilter.java:63)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:78)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:354)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1146)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:679)
2014-01-15 20:33:48,602 INFO [HTTP-Thread-5]: received message:
Posted by voltron43 at Jan 15, 2014 20:38
In order to retrieve all the id fields from the devices you should use this expression:
$.devices..id

After adding this expression to the JSONPath expression field and adding a password as ERIC has stated below, I still receive an "Internal Sever Error".

Posted by voltron43 at Jan 15, 2014 20:45

POST method now works. As it turns out, I was missing the Content-Type field in the POST request. Apparently, according to this comment, the Content-Type field is only present in the 2.14 Designer.

NOTE: Do be careful if you decide to use the 2.14 preview version - it is NOT backwards compatible with the current 2.13.x version. If you log back in to 2.13 version of the designer, you may lose your account data.

Final PushBullet POST fields:

Protocol: HTTP
URL: https://api.pushbullet.com/api/pushes
HTTP Method: POST
Content-Type: application/x-www-form-urlencoded
Workload: device_id=xxxxxxxxxxxxxxxx&type=note&title=Title&body=Body
Username: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Password: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Any idea when Designer will be updated?

Posted by voltron43 at Jan 22, 2014 10:31
Document generated by Confluence on Jun 05, 2016 09:31