Call this operation to update a specified rule.

Request parameters

Parameter Type Required? Description
Action String Yes The operation that you want to perform. Set the value to UpdateRule.
RuleId Long  Yes The ID of the rule that you want to update.
Name String Yes The rule name. The name can be 4 to 30 characters in length and can contain English letters, digits, and underscores (_).
ProductKey String No The unique identifier of the product that uses this rule.
ShortTopic String No

The topic (does not contain the ProductKey hierarchy) to which this rule applies. A ShortTopic is in the following format: ${deviceName}/topicShortName. ${deviceName} is the name of the specified device, and topicShortName is the custom hierarchy of the topic.

You can call QueryDevice to query the devices of a product and view the DeviceName values.

You can call QueryProductTopic to query all the topic categories of a product and view the TopicShortName values.

Example:

  • ${deviceName}/thing/event/property/post is the ShortTopic of a system topic. For the ${deviceName} hierarchy, you can use the + symbol to include all the device names under the specified product.

  • ${deviceName}/user/get is the ShortTopic of a custom topic.

    Wildcards + and # are supported when you specify custom topics.
    • For the ${deviceName} hierarchy, you can use the + symbol to include all the device names under the specified product.
    • Then for the following hierarchies, you can specify /user/#. # includes all the hierarchies following /user.

      For information about to use wildcards in topics, see Wildcards in topics.

  • ${deviceName} is the ShortTopic of the topic with device status information.
Select String No

The SQL SELECT statement. For more information, see the SQL syntax.

Note The value is the value of SELECT in the SQL statements. For example, if the SELECT statement is Select a,b,c, set the parameter value to a,b,c.
RuleDesc String No The description of the rule. You can enter a description with up to 100 characters.
Where String No

The trigger of the rule. For more information, see the SQL syntax.

Note The value is the value of WHERE in the SQL statements. For example, if the WHERE clause is Where a>10, set the parameter value to a>10.
TopicType Integer   No
  • 0: Indicates system topics, including:

    • /thing/event/property/post This category of topics contain property messages reported by devices.
    • /thing/event/${tsl.event.identifier}/post Values of the variable ${tsl.event.identifier} are the identifiers of events in TSL. This category of topics contain event messages reported by devices.
    • thing/lifecycle This category of topics contain device lifecycle change messages.
    • /thing/downlink/reply/message This category of topics contain messages that devices send to IoT Platform as responses to commands from IoT Platform.
    • /thing/list/found This category of topics contain sub-device information reported by gateways.
    • thing/topo/lifecycle This category of topics contain device topological relationship change messages.
  • 1: Indicates custom topics.

  • 2: Indicates the topic for device status change messages. Topic format: /as/mqtt/status/${productKey}/${deviceName}.

Common request parameters - Yes See Common parameters.

Response parameters

Parameter Type Description
RequestId String The globally unique ID generated by Alibaba Cloud for the request.
Success Boolean Indicates whether the call is successful. A value of true indicates that the call is successful. A value of false indicates that the call failed.
ErrorMessage String The error message returned when the call fails.
Code String The error code returned when the call fails. For more information on error codes, see Error codes.

Examples

Request example

https://iot.cn-shanghai.aliyuncs.com/?Action=UpdateRule
&RuleId=1000
&Name=test_2
&ProductKey=al*********
&ShortTopic=+/get
&Select=a,b,c
&RuleDesc=test
&Where=a>10
&TopicType=1
&Common request parameters

Response example

{
    "RequestId":"9A2F243E-17FE-4846-BAB5-D02A25155AC4",
    "Success":true
}