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.
Important If the Thing Specification Language (TSL) data is of the float or double type, the parameter values that correspond to the TSL data contain at least one decimal place. Examples: 10.0 and 11.1.

QPS limits

Each Alibaba Cloud account can run up to 50 queries per second (QPS).

Note The RAM users of an Alibaba Cloud account share the quota of the account.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

ParameterTypeRequiredExampleDescription
ActionStringYesSetDeviceDesiredProperty

The operation that you want to perform. Set the value to SetDeviceDesiredProperty.

ItemsStringYes{"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.

  • Key specifies the identifier of the property. You can view the property identifier on the Define Feature tab of the Product Details page in the IoT Platform console. You can also call the QueryThingModel operation and view the property identifier in the returned TSL data.

    If the temperature property belongs to a custom module named testFb, this parameter is set to {"testFb:temperature":35}.
    Note The specified property must allow read/write access. If you specify a read-only property, the setting fails. The property identifier must be unique.
  • Value specifies the desired value of the property. The value must match the data type and value range that are defined for the property.
    Note If you set Value to null, the desired value of the property is cleared.
VersionsStringYes{"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}.

  • Key specifies the identifier of the property. You can view the property identifier on the Define Feature tab of the Product Details page in the IoT Platform console.
    Note The property identifier must be unique.
  • Value specifies the version number of the desired property value.

    The first time you specify a desired property value, set the Value parameter to 0. After you set the property value, the version number changes to 1. Each time you specify a desired property value, IoT Platform automatically increases the version number by 1. The second time that you specify a desired property value, the version number changes to 2. The third time that you specify a desired property value, set the version number to 2. After you specify the desired property value, the version number changes to 3.
    Note If the version number that you specify for this parameter is not the current version number, the server rejects the request. If you are not sure about the current version number, you do not need to specify a version number. However, you must enter a valid JSON object {}.
IotInstanceIdStringNoiot_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
  • If your instance has an ID, you must specify the ID for this parameter. Otherwise, the call fails.
  • If no Overview page or ID is generated for your instance, you do not need to configure this parameter.

For more information, see Overview.

IotIdStringNoQ7uOhVRdZRRlDnTLv****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.
DeviceNameStringNolight

The name of the device.

Important If you specify a value for this parameter, you must also specify a value for the ProductKey parameter.
ProductKeyStringNoa1BwAGV****

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

ParameterTypeExampleDescription
CodeStringiot.system.SystemException

The error code returned if the call fails. For more information, see Error codes.

DataStruct

The data returned if the call is successful. For more information, see the following parameters.

MessageIdString300511751

The ID of the message that IoT Platform sends to the device to specify desired property values.

VersionsString{\"Temperature\":2}

The current version numbers of the desired property values.

ErrorMessageStringA system exception occurred.

The error message returned if the call fails.

RequestIdStringE55E50B7-40EE-4B6B-8BBE-D3ED55CCF565

The ID of the request.

SuccessBooleantrue

Indicates whether the call was successful. Valid values:

  • true: The call was successful.
  • false: The call failed.

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.