Specifies desired values for multiple device properties at a time.
Usage notes
- You cannot query the desired values of read-only properties.
- You can specify up to 10 desired property values in a call.
- After a device is created, the value of the Version parameter is 0. If you want to configure the Version parameter the first time you specify a desired property value, set the Version parameter to 0.
QPS limits
Each Alibaba Cloud account can run up to 50 queries per second (QPS).
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | SetDeviceDesiredProperty | The operation that you want to perform. Set the value to SetDeviceDesiredProperty. |
Items | String | Yes | {"Temperature":35} | The property value that you want to specify. The value of this parameter is a JSON string. Format: Key:Value. Example: {"Temperature":35}. You can specify up to 10 desired property values.
|
Versions | String | Yes | {"Temperature":2} | The version number of the desired property value. The value of this parameter is a JSON string. Format: Key:Value. Example: {"Temperature":2}.
|
IotInstanceId | String | No | iot_instc_pu****_c*-v64******** | The ID of the instance. You can view the ID of the instance on the Overview page in the IoT Platform console. Important
For more information, see Overview. |
IotId | String | No | Q7uOhVRdZRRlDnTLv****00100 | The ID of the device. The ID is a unique identifier that is issued by IoT Platform to the device. Important The IotId parameter specifies a globally unique identifier (GUID) for the device. The value of the IotId parameter corresponds to a combination of the values of the ProductKey and DeviceName parameters. If you specify a value for this parameter, you do not need to specify the ProductKey or DeviceName parameters. If you specify values for the IotId, ProductKey, and DeviceName parameters, the value of the IotId parameter takes precedence. |
DeviceName | String | No | light | The name of the device. Important If you specify a value for this parameter, you must also specify a value for the ProductKey parameter. |
ProductKey | String | No | a1BwAGV**** | The ProductKey of the product to which the device belongs. Important If you configure this parameter, you must also specify a value for the DeviceName parameter. |
In addition to the preceding operation-specific request parameters, you must also configure common request parameters when you call this operation. For more information about common request parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
Code | String | iot.system.SystemException | The error code returned if the call fails. For more information, see Error codes. |
Data | Struct | The data returned if the call is successful. For more information, see the following parameters. | |
MessageId | String | 300511751 | The ID of the message that IoT Platform sends to the device to specify desired property values. |
Versions | String | {\"Temperature\":2} | The current version numbers of the desired property values. |
ErrorMessage | String | A system exception occurred. | The error message returned if the call fails. |
RequestId | String | E55E50B7-40EE-4B6B-8BBE-D3ED55CCF565 | The ID of the request. |
Success | Boolean | true | Indicates whether the call was successful. Valid values:
|
Examples
Sample requests
https://iot.cn-shanghai.aliyuncs.com/?Action=SetDeviceDesiredProperty
&ProductKey=a1BwAGV****
&DeviceName=device1
&Items=%7B%22LightAdjustLevel%22%3A1%7D
&Versions=%7B%22LightAdjustLevel%22%3A10%7D
&<Common request parameters>
Sample success responses
XML
format
<SetDeviceDesiredPropertyResponse>
<Data>
<MessageId>300511751</MessageId>
<Versions>{"LightAdjustLevel":2}</Versions>
</Data>
<RequestId>AADE79D2-B328-4FC6-A3E0-34BB23BCA440</RequestId>
<Success>true</Success>
</SetDeviceDesiredPropertyResponse>
JSON
format
{
"Data": {
"MessageId": "300511751",
"Versions": "{\"LightAdjustLeve\":2}"
},
"RequestId": "AADE79D2-B328-4FC6-A3E0-34BB23BCA440",
"Success": true
}
Error codes
For a list of error codes, see Service error codes.