Adds device topological relationships in batches.

Restrictions

  • Up to 10 devices can be added to a gateway each time the API operation is called.
  • The API operation caller must be the gateway owner.
  • A single Alibaba Cloud account calls the API operation with a maximum QPS of 5. RAM users share the quota of the Alibaba Cloud account.
  • If a device already has been bound to a gateway device, its original gateway is replaced with the current gateway.
  • If one of the devices fails to establish the topological relationship with the gateway, the system rolls back and all devices fail to establish topological relationships with the gateway.

Request parameters

Parameter Type Required Description
Action String Yes The operation that you want to perform. Set the value to BatchAddThingTopo.
GwProductKey String Yes The key of the product to which the gateway belongs.
GwDeviceName String Yes The name of the gateway.
TopoAddItemList List<TopoAddItem> Yes The list of devices for which you want to add a topological relationship. For more information, see table TopoAddItem.
Common request parameters N/A Yes For more information, see Common parameters.
Table 1. TopoAddItem
Parameter Type Required Description
ProductKey String Yes The key of the product to which the device belongs.
DeviceName String Yes The name of the device.
Sign String Yes The signature for adding the topological relationship.

Set the Sign parameter to the calculated result of SignMethod(deviceSecret,content).

The value of the content parameter is device parameters (except Sign and SignMethod) submitted to the server in an alphabetized list without any delimiters.

For example, assume that the input device parameters are ClientId=868575026974305, DeviceName=868575026974305, ProductKey=a1PB5fp1234, SignMethod=hmacmd5, and deviceSecret=1234. The signature calculation method is hmacmd5(1234, clientId868575026974305deviceName868575026974305productKeya1PB5fpX1234), and the calculation result is C1C1606D61884C5F16C9EA6622E5****.

SignMethod String Yes The signature method. Valid values: hmacSha1, hmacSha256, hmacMd5, and Sha256. The value is case-insensitive.
Timestamp String No The timestamp. The time must be in UTC. This parameter is optional. If you specify this parameter, you must use its value to calculate the signature.
ClientId String No The client ID of the device, which can either be the serial number or MAC address of the device. This parameter is optional. If you specify this parameter, you must use its value to calculate the signature.

Response parameters

Parameter Type Description
RequestId String The globally unique ID generated by Alibaba Cloud for the request.
Success Boolean Indicates whether the call was successful. true indicates that the call was successful. false indicates that the call failed.
ErrorMessage String The error message returned if the call failed.
Code String For information about error codes, see Error codes.

Examples

Sample request

https://iot.cn-shanghai.aliyuncs.com/?Action=BatchAddThingTopo
&GwProductKey=a1duisa****
&GwDeviceName=tydhnay16shc6
&TopoAddItem.1.ProductKey=a1rYuVF****
&TopoAddItem.1.DeviceName=SR8FiTu1R9tlUR2V1bmi
&TopoAddItem.1.Sign=1asded9c****
&TopoAddItem.1.SignMethod=hmacMd5
&TopoAddItem.2.ProductKey=a1yrZMH****
&TopoAddItem.2.DeviceName=RkQ8CFtNpDok4BEunymt
&TopoAddItem.2.Sign=438ac4de****
&TopoAddItem.2.SignMethod=hmacMd5
&Common request parameters

Sample responses

  • JSON format
    {
      "RequestId": "2E19BDAF-0FD0-4608-9F41-82D230CFEE38",
      "Success": true
    }
  • XML format
    <? xml version="1.0" encoding="UTF-8"? >
     <BatchAddThingTopoResponse>
          <RequestId>2E19BDAF-0FD0-4608-9F41-82D230CFEE38</RequestId>
          <Success>true</Success>
      </BatchAddThingTopoResponse>