Call this operation to query details about a specified rule.

Request parameters

Parameter Type Required Description
Action String Yes The operation that you want to perform. Set the value to GetRule.
RuleId Long Yes The ID of the rule that you want to query.
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 has failed.
ErrorMessage String The error message returned when the call fails.
Code String The error code returned when the call fails. For more information about error codes, see Error codes.
RuleInfo RuleInfo The rule details returned when the call is successful. For more information, see the following table RuleInfo.
Table 1. RuleInfo
Parameter Type Description
CreateUserId Long The ID of the user who created this rule.
Created String The CST time when the rule was created.
DataType String The type of data that this rule processes. Values include: JSON and BINARY.
Id Long The rule ID.
Modified String The most recent time when the rule was updated.
Name String The rule name.
ProductKey String The unique identifier of the product that uses this rule.
RuleDesc String The description of the rule.
Select String The value of SELECT in the SQL statements of the rule.
ShortTopic String 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.
Status String

The running status of this rule. Values:

RUNNING: The rule is running.

STOP: The rule is disabled.

Topic String The full name of the topic to which this rule applies. The topic name is in the format of ${productKey}/${deviceName}/ topicShortName.
Where String The value of WHERE in the SQL statements of this rule.
topicType Integer

If you have completed the SQL statements for the rule, the returned values are:

  • 0: Indicates the topic is an upstream topic of a Pro Edition product.

  • 1: Indicates the topic is a custom topic.

  • 2: Indicates the topic of device status change information.

If you have not set SQL statements for the rule, the returned value is -1.

UtcCreated String The UTC time when the rule was created.
UtcModified String The most recent time when the rule was updated.

Examples

Request example

https://iot.cn-shanghai.aliyuncs.com/?Action=GetRule
&RuleId=1000
&Public Request Parameters

Response example

  • JSON format
    {
    	"RequestId": "58D4CEC0-3E95-4DBE-AFC1-809D1400E52F",
    	"Success": true,
    	"RuleInfo": {
    		"DataType": "JSON",
    		"ShortTopic": "+/#",
    		"ProductKey": "a1KiV******",
    		"UtcModified": "2019-02-28T06:20:58.000Z",
    		"CreateUserId": "12******85529123",
    		"UtcCreated": "2019-02-28T06:14:33.000Z",
    		"Name": "iotrules",
    		"Status": "STOP",
    		"Select": "deviceName() as deviceName",
    		"Created": "Thu Feb 28 14:14:33 CST 2019",
    		"Modified": "Thu Feb 28 14:20:58 CST 2019",
    		"TopicType": 1,
    		"Topic": "/a1KiV******/+/#",
    		"Id": 100000
    	}
    }
  • XML format
    <?xml version="1.0" encoding="UTF-8" ?>
    <GetRuleResponse>
    	<RequestId>58D4CEC0-3E95-4DBE-AFC1-809D1400E52F</RequestId>
    	<Success>true</Success>
    	<RuleInfo>
    		<DataType>JSON</DataType>
    		<ShortTopic>+/#</ShortTopic>
    		<ProductKey>a1KiV******</ProductKey>
    		<UtcModified>2019-02-28T06:20:58.000Z</UtcModified>
    		<CreateUserId>1231579085******</CreateUserId>
    		<UtcCreated>2019-02-28T06:14:33.000Z</UtcCreated>
    		<Name>iotrules</Name>
    		<Status>STOP</Status>
    		<Select>deviceName() as deviceName</Select>
    		<Created>Thu Feb 28 14:14:33 CST 2019</Created>
    		<Modified>Thu Feb 28 14:20:58 CST 2019</Modified>
    		<TopicType>1</TopicType>
    		<Topic>/a1KiV******/+/#</Topic>
    		<Id>100000</Id>
    	</RuleInfo>
    </GetRuleResponse>