4 years, 1 month ago.

registering a notification callback URL for mbed connector

Hi, I want to register my public web app to mbed device connector using notification callback. My web app is an IBM node red app wich has an URL like <mywebapp>.mybluemix.net/GET and it responses with simple "Hello World". I've created a flow which uses PUT to send the notification URL to mbed connector but its response with the following: "Connection to [https://<mywebapp>.mybluemix.net/GET] returned 404, cannot accept as callback uri" I know I am missing something in my flow to receive the notifications from mbed connector. I didn't find any similar examples about registering a node red web app to mbed connector notification call back, but do you have any idea how to fix this? Thanks.

1 Answer

4 years, 1 month ago.

Hi Masoud,

I think I know how to fix your problem, but first I want to double check I understand your current flow. Is this correct?

1. "<mywebapp>.mybluemix.net/GET" is a link that let's you submit GET requests (AKA what your web browser does) and it responds with "Hello World"

2. You have an action you can trigger in your node red app that submits a PUT request to https://api.connector.mbed.org/v2/notification/callback with the "Authorization: Bearer YOUR_ACCESS_KEY" header set. You should be setting a JSON body that looks like:

    "url": "https://<mywebapp>.mybluemix.net/GET"

3. Upon triggering this action you get the 404 error.

If this is what's occurring, then I think I know the problem. The action that's handling the route "<mywebapp>.mybluemix.net/GET" needs to be able to handle PUT requests, not just GET requests. mbed Device Connector will issue a test PUT request to the URL you specify before your initial PUT request finishes. If it isn't able to successfully make a PUT request, it will return the 404 error you're seeing.

Hope that helps you. For more information I suggest (if you haven't done so already) reading the mbed Device Connector REST API docs here: https://docs.mbed.com/docs/mbed-device-connector-web-interfaces/en/latest/api-reference/#registering-a-notification-callback


Accepted Answer

Thank you for the answer. First of all here is my function node before a PUT request to https://api.connector.mbed.com/v2/notification/callback : msg.headers = { "Authorization" : "Bearer <my key>, }; msg.payload ={"url": "<mywebapp>.mybluemix.net/GET"}; return msg;

I think this node is ok. I don't know how to implement your suggest (about PUT request) to my node red app. Can you explain a little more how to do this?

posted by Masoud R. 15 Feb 2017

That all looks ok, I'm afraid I don't know how to implement a node red node that accepts PUT requests either! Perhaps you could consult the bluemix docs?

posted by Brian Daniels 15 Feb 2017

Thanks, I finally get it working just put a "http input /PUT" and a "http out node". That is it. Now I registered my URL in mbed connector and now I am able to receive asyn responses.

posted by Masoud R. 15 Feb 2017

Fantastic! Good to hear :)

posted by Brian Daniels 15 Feb 2017