Imports multiple external data records to IoT Platform at a time. Data that is imported to IoT Platform by calling the BatchAddDataForApiSource operation is called the data of an API data source. You can import multiple data records from an on-premises server or other platforms to IoT Platform for data analysis and processing.
Usage notes
You can import up to 100 data records at a time in a single call.
QPS limits
You can call this API operation up to three times per second per account.
Debugging
Request parameters
| Parameter | Type | Required | Example | Description |
| Action | String | Yes | BatchAddDataForApiSource | The operation that you want to perform. Set the value to BatchAddDataForApiSource. |
| ApiId | String | Yes | cxatswiniekxw*** | The ID of the API data source. |
| ContentList | Json | Yes | [{"key":"value1","ts":1637658286000},{"key":"value2","ts":1637658287000}] | The details of the data records that you want to import to IoT Platform. The value is a JSON list.
|
| IotInstanceId | String | Yes | iot-0pp1n***** | The ID of the instance. You can view 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 | Map | {"count":2,"hasNext":false,"items":[{"key":"value1","ts":1637658286000,"id":1234567890},{"key":"value2","ts":1637658287000,"id":1234567891}],"pageNum":1,"pageSize":2} | The details of the data records that are imported to IoT Platform. The details include the IDs of the data records. You can obtain the ID of a data record from the id field. |
| ErrorMessage | String | A system exception occurred. | The error message returned if the call fails. |
| RequestId | String | BB71E443-4447-4024-A000-EDE09922891E | The ID of the request. |
| Success | Boolean | true | Indicates whether the call was successful. Valid values:
|
Examples
Sample requests
http(s)://iot.cn-shanghai.aliyuncs.com/?Action=BatchAddDataForApiSource
&ApiId=cxatswiniekxw***
&ContentList=[{"key":"value1","ts":1637658286000},{"key":"value2","ts":1637658287000}]
&IotInstanceId=iot-0pp1n*****
&<Common request parameters>
Sample success responses
XML format
<BatchAddDataForApiSourceResponse>
<RequestId>BB71E443-4447-4024-A000-EDE09922891E</RequestId>
<Data>{"count":2,"hasNext":false,"items":[{"key":"value1","ts":1637658286000,"id":1234567890},{"key":"value2","ts":1637658287000,"id":1234567891}],"pageNum":1,"pageSize":2}</Data>
<Code></Code>
<Success>true</Success>
</BatchAddDataForApiSourceResponse>
JSON format
{
"RequestId": "BB71E443-4447-4024-A000-EDE09922891E",
"Data": "{\"count\":2,\"hasNext\":false,\"items\":[{\"key\":\"value1\",\"ts\":1637658286000,\"id\":1234567890},{\"key\":\"value2\",\"ts\":1637658287000,\"id\":1234567891}],\"pageNum\":1,\"pageSize\":2}",
"Code": "",
"Success": true
}
Error codes
For a list of error codes, see Service error codes.