Reputation: 217
I would like to receive IOT Hub messages from an endpoint. With client side Javascript and REST.
I used this article https://msdn.microsoft.com/nl-nl/library/mt590786.aspx for creating the URL.
This is my code:
function readIOTHub()
{
$.getJson("https://MyIOTHub.azure-devices.net/devices/device1/messages/devicebound?api-version=2016-02-03", function(result)
{
alert(result);
});
}
But my Request is not receiving any messages. Does someone know how to receive messages from IOT Hub, with Javascript REST?
Upvotes: 1
Views: 1006
Reputation: 432
You might want to take a look at the Node.js sdk for the IoT hubs, but then again this is in the context of Node.js.
If you are ok with node.js, it becomes much simpler.
Hope this helps!
Mert
Upvotes: 0
Reputation: 1635
I don't think this is currently possible, first because, from what I see, Azure IoT hub REST API does not issue CORS requests (i.e. they don't write in the CORS header access-control-allow-origin), so your JS client can't access it from within the browser.
Upvotes: 1