我正在尝试使用Rest API更新Iothub设备状态。 链接:https://docs.microsoft.com/en-us/rest/api/iothub/service/createorupdatedevice
我能够使用它创建一个新设备,但无法更新任何内容。
请求:
{ "eTag": "NTkyMDYyMzsSU2", "status": "disabled", "deviceId": "xyz" }
响应:
{ "Message": "ErrorCode:DeviceAlreadyExists;A device with ID 'xyz' is already registered.", "ExceptionMessage": "Tracking ID:8a748b37ssda964671a75f0a3fb1ba5a7b-G:8-TimeStamp:04/29/2019 14:53:52" }
答案 0 :(得分:0)
添加以下标题:
if-match:*
此外,必须在有效负载中添加设备 authentication 属性,否则将为其自动重新生成服务。下面的示例使用 symmetricKey :
{
"status": "disabled",
"deviceId": "xyz",
"authentication": {
"symmetricKey": {
"primaryKey": "******",
"secondaryKey": "*****"
}
}
}