Subscribes to one or more topics for a device.

Usage notes

  • The device that needs to subscribe to topics must be connected to IoT Platform and online.
  • You can call this operation to subscribe to the topics of a specified device. You can specify a maximum of 10 topics in a single call.

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 SubscribeTopic

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

DeviceName String Yes device1

The DeviceName of the device to which the topic belongs.

ProductKey String Yes a1Q5XoY***

The ProductKey of the product to which the device belongs.

Topic.N RepeatList Yes /a1Q5XoY***/device1/user/get

The topics to which you want to subscribe. You can specify a maximum of 10 topics.

The topics must have the Subscribe or Publish and Subscribe permissions.

IotInstanceId String No iot-06***

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 request fails.

RequestId String BB71E443-4447-4024-A000-EDE09922891E

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=SubscribeTopic
&DeviceName=device1
&ProductKey=a1Q5XoY***
&Topic.1=/a1Q5XoY***/device1/user/get
&Topic.2=/a1Q5XoY***/device1/user/add
&<Common request parameters>

Sample success responses

XML format

<SubscribeTopicResponse>
  <RequestId>32B9828A-25DD-48E2-8E26-D1664B341940</RequestId>
  <Success>true</Success>
</SubscribeTopicResponse>

JSON format

{
    "RequestId": "32B9828A-25DD-48E2-8E26-D1664B341940",
    "Success": true
}