Adds multiple devices to a Standard instance or a Message Queuing Telemetry Transport (MQTT) gateway product at a time.
Usage notes
Before you add devices to an MQTT gateway product, make sure that an MQTT gateway and the related product are created and the ProductKey of the product is obtained. For more information, see Create an MQTT gateway.
QPS limits
You can call this API operation up to 10 times per second per account.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | BatchImportDevice | The operation that you want to perform. Set the value to BatchImportDevice. |
ProductKey | String | Yes | a1BwAGV**** | The ProductKey of the product to which the device belongs. A ProductKey is the unique identifier of a product in IoT Platform. You can use the IoT Platform console or call the QueryProductList operation to view the information about all products in the current account. |
DeviceList.N.DeviceName | String | Yes | device1 | The DeviceName of the device. The DeviceName must be 4 to 32 characters in length, and can contain letters, digits, hyphens (-), underscores (_), at signs (@), periods (.), and colons (:). The DeviceName must be unique in the product. Note You can specify up to 10,000 DeviceNames in a single call. If the number of DeviceNames exceeds the limit, the excess DeviceNames are discarded. |
DeviceList.N.DeviceSecret | String | Yes | b4d43f7******10ba5e5 | The DeviceSecret of the device. The DeviceSecret must be 1 to 32 characters in length, and can contain letters, digits, hyphens (-), underscores (_), at signs (@), periods (.), and colons (:). Note You can specify up to 10,000 DeviceSecrets in a single call. If the number of DeviceSecrets exceeds the limit, the excess DeviceSecrets are discarded. |
DeviceList.N.Sn | String | No | QC4******001 | The serial number (SN) of the device. The SN must be 1 to 64 characters in length, and can contain letters, digits, and underscores (_). Note You can specify up to 10,000 SNs in a single call. If the number of SNs exceeds the limit, the excess SNs are discarded. |
IotInstanceId | String | No | iot-1n8t**** | The ID of the instance. You can obtain the ID of the instance on the Overview page in the IoT Platform console. Important
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 about common request parameters, see Common parameters.
Response parameters
Parameter | Type | Example | Description |
Code | String | iot.system.SystemException | The error code returned if the call fails. For more information about error codes, see Error codes. |
Data | Struct | The data returned if the call is successful. |
|
ApplyId | Long | 1295006 | The application ID (ApplyId) returned for the request if the call is successful. |
InvalidDetailList | Array of InvalidDetailList | The details of invalid devices returned if the call fails. |
|
InvalidDetailList | |||
DeviceName | String | light% | The DeviceName of the device. |
DeviceSecret | String | ^67$ | The DeviceSecret of the device. |
ErrorMsg | String | The device name is illegal. | The error message returned if the call fails. |
Sn | String | QC4001# | The SN of the device. |
InvalidDeviceNameList | List | { "InvalidDeviceNameList": [ "APT$", "aw" ] } | The DeviceNames of the invalid devices returned if the call fails. |
InvalidDeviceSecretList | List | { "InvalidDeviceSecretList": [ "^67$", "1" ] } | The DeviceSecrets of the invalid devices returned if the call fails. |
InvalidSnList | List | { "InvalidSnList": [ "" ] } | The SNs of the invalid devices returned if the call fails. |
RepeatedDeviceNameList | List | { "RepeatedDeviceNameList": [ "abcd", "asdf" ] } | The duplicate DeviceNames returned if the call fails. |
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. Valid values:
|
Description
Sample requests
http(s)://iot.cn-shanghai.aliyuncs.com/?Action=BatchImportDevice
&DeviceList.1.DeviceName=device1
&DeviceList.2.DeviceName=device2
&DeviceList.1.DeviceSecret=b4d43f7******10ba5e5
&DeviceList.2.DeviceSecret=912179******700210b4
&ProductKey=a1BwAGV****
&IotInstanceId=iot-1n8t****
&<Common request parameters>
Sample success responses
XML
format
<BatchImportDeviceResponse>
<RequestId>E4C0FF92-2A86-41DB-92D3-73B60310D25E</RequestId>
<Data>
<ApplyId>1295006</ApplyId>
</Data>
<Success>true</Success>
</BatchImportDeviceResponse>
JSON
format
{
"RequestId": "E4C0FF92-2A86-41DB-92D3-73B60310D25E",
"Data": {
"ApplyId": 1295006
},
"Success": true
}
Error codes
HttpCode | Error code | Error message | Description |
400 | iot.device.TooManyDeviceNamesPerRequest | The devices you query exceed the maximum number. | The number of DeviceNames that you specified in the request exceeds the limit. |
400 | iot.device.ApplyManyDevicesFailed | An error occurred while creating multiple devices. | The system failed to create multiple devices at a time. |
400 | iot.device.DeviceNumerExceedTenant | The device total number beyond limit. | The number of devices exceeds the limit. |
For a list of error codes, see Service error codes.