云到设备 Azure IoT REST API [英] Cloud-to-device Azure IoT REST API
问题描述
我探索了如何使用 Azure REST API 将数据从设备发送到云.它可以无缝地工作,没有任何问题.我没有找到关于使用Azure IoT Hub REST APIs"将云到设备消息发送到 Arduino 板的好文章.有人可以就此提供建议
I explored on sending data from Device to Cloud using Azure REST Apis. It is working seamlessly without any issues. I'm not finding good articles on sending Cloud-to-Device messages to Arduino board using "Azure IoT Hub REST Apis". Could some one provide suggestions on this
推荐答案
您也可以像 azure 门户那样发送请求.来自 AZ 门户的所有 C2D 都通过此端点发送 https://main.iothub.ext.azure.com/api/Service/SendMessage/ 并且有效负载是一个如下所示的 json:
You could also send the request as the azure portal does it. All C2D from AZ Portal are sent through this Endpoint https://main.iothub.ext.azure.com/api/Service/SendMessage/ and the payload is a json that look like this:
{
"hostName": "iothub-hostname",
"owner": "twinUpdate",
"key": "key for the iothub",
"deviceID": "your device on that hub",
"body": "{\"test\": \"This is a test over postman\"}",
"properties": "[]"
}
请记住,您需要添加具有有效承载令牌的授权标头.您可以在登录 AZ Portal 时获得此信息.
Keep in mind that you need to add an Authorization Header with valid Bearer token. You can get this when you log in to AZ Portal.
这篇关于云到设备 Azure IoT REST API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!