Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/466.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有Javascript的Azure IOT Hub Rest API_Javascript_Rest_Azure Iot Hub - Fatal编程技术网

带有Javascript的Azure IOT Hub Rest API

带有Javascript的Azure IOT Hub Rest API,javascript,rest,azure-iot-hub,Javascript,Rest,Azure Iot Hub,我想从端点接收物联网中心消息。使用客户端Javascript和REST 我使用本文创建URL 这是我的代码: function readIOTHub() { $.getJson("https://MyIOTHub.azure-devices.net/devices/device1/messages/devicebound?api-version=2016-02-03", function(result) { alert(result); }); } 但是我的请求没有收到任何

我想从端点接收物联网中心消息。使用客户端Javascript和REST

我使用本文创建URL

这是我的代码:

function readIOTHub()
{
  $.getJson("https://MyIOTHub.azure-devices.net/devices/device1/messages/devicebound?api-version=2016-02-03", function(result)
  {
    alert(result);
  });
}
但是我的请求没有收到任何消息。
有人知道如何使用Javascript REST从IOT Hub接收消息吗?

我认为目前不可能做到这一点,首先,据我所见,Azure IOT Hub REST API不发出CORS请求(即,他们不在CORS标头中写入访问控制允许来源),因此,您的JS客户端无法从浏览器中访问它。

您可能希望查看IoT集线器的Node.JS sdk,但这也是Node.JS的上下文

如果您对node.js没有意见,那么它会变得简单得多

希望这有帮助


Mert

curl/node.js Azure IoT Central的示例。。基本上,该示例向您展示了身份验证和通过HTTP请求向Azure IoT Hub和Azure IoT DPS发送事件