Adds a topic to a data source in the rules engine.

Usage notes

Before you call the CreateDataSourceItem operation, you must create a data source. For more information, see "Step 1 to Step 6" in the Create a data source topic. Then, perform the following steps to view the ID of the data source: Log on to the IoT Platform console and click the name of the instance to which the data source belongs. Choose Rules Engine > Data Forwarding. On the Data Source tab, view the ID of the data source.

QPS limits

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

Note The RAM users of an Alibaba Cloud account share the quota of the Alibaba Cloud 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

Parameter Type Required Example Description
Action String Yes CreateDataSourceItem

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

DataSourceId Long Yes 1002

The ID of the data source.

Topic String Yes /as/mqtt/status/gy***z/+

The topic that you want to add to the data source in the rules engine. Format: /${productKey}/${deviceName}/topicShortName. ${productKey} specifies the ProductKey of the product to which a device belongs. ${deviceName} specifies the name of the device. topicShortName specifies the custom name of the topic.

  • The format of basic communication topics or TSL communication topics is /${productKey}/${deviceName}/topicShortName. You can replace ${deviceName} with the + wildcard. The wildcard specifies that the topic applies to all devices in the product. Valid values of topicShortName:
    • /thing/event/property/post: submits the property data of a device.
    • /thing/event/${tsl.event.identifier}/post: submits the event data of a device. ${tsl.event.identifier} specifies the identifier of an event in the TSL model.
    • /thing/lifecycle: submits device lifecycle changes.
    • /thing/downlink/reply/message: sends a response to a request from IoT Platform.
    • /thing/list/found: submits the data when a gateway detects a new sub-device.
    • /thing/topo/lifecycle: submits device topology changes.
    • /thing/event/property/history/post: submits historical property data of a device.
    • /thing/event/${tsl.event.identifier}/post: submits the historical event data of a device. ${tsl.event.identifier} specifies the identifier of an event in the TSL.
    • /ota/upgrade: submits OTA update statuses.
    • /ota/version/post: submits OTA module versions.
    • /thing/deviceinfo/update: submits device tag changes.

      ${packageId}/${jobId}/ota/job/status: submits the status of each OTA update batch. This topic is a basic communication topic. ${packageId} specifies the ID of the update package. ${jobId} specifies the ID of the update batch.

  • The format of custom topics is /${productKey}/${deviceName}/user/#. Example: /${productKey}/${deviceName}/user/get.

    You can call the QueryProductTopic operation to view all custom topics of the product.

    When you specify a custom topic, you can use the + and # wildcards.

    • You can replace ${deviceName} with the + wildcard. The wildcard specifies that the topic applies to all devices in the product.
    • You can replace the fields that follow ${deviceName} with /user/#. The # wildcard specifies that the topic applies to all fields that follow/user.
  • The format of the topics that are used to submit device status changes is /as/mqtt/status/${productKey}/${deviceName}.

    You can use the + wildcard. In this case, the status changes of all devices in the product are submitted.

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

For more information about the data formats of topics, see Data formats.

IotInstanceId String No iot-0pp1n8t***

The ID of the instance. You can view the ID of the instance on the Overview page in the IoT Platform console.

Notice
  • 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.

In addition to the preceding operation-specific request parameters, you must configure common request parameters when you call this operation. For more information, see Common request 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.

ErrorMessage String A system exception occurred.

The error message returned if the call fails.

RequestId String E4C0FF92-2A86-41DB-92D3-73B60310D25E

The ID of the request.

Success Boolean true

Indicates whether the call was successful.

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

Examples

Sample requests

http(s)://iot.cn-shanghai.aliyuncs.com/?Action=CreateDataSourceItem
&DataSourceId=1002
&Topic=/as/mqtt/status/gy***z/+
&<Common request parameters>

Sample success responses

XML format

<CreateDataSourceItemResponse>
  <RequestId>E4C0FF92-2A86-41DB-92D3-73B60310D25E</RequestId>
  <Success>true</Success>
</CreateDataSourceItemResponse>

JSON format

{
    "RequestId": "E4C0FF92-2A86-41DB-92D3-73B60310D25E",
    "Success": true
}