Creates a data download task.
Usage notes
After you call the CreateDownloadDataJob operation to create a download task, the task is displayed in the IoT Platform console. On the Exporting tab of the corresponding table, you can view the logs of the task and download the required file.
If you call the CreateDownloadDataJob operation to create a download task, a message that can be pushed over Advanced Message Queuing Protocol (AMQP) is generated. Set the
consumerGroupId
parameter of the message todop_aliyun_group_name
The content of the message includes the status of the download task. You can call the GetDownloadFile operation to obtain the download link of the corresponding file or view the error messages of the download task based on the status.
Limits
You can create only one download task for a data instance each time. You can create a download task only after the previous download task is complete. Otherwise, an error message indicating that the number of download tasks exceeds the limit appears.
You can download only data of the previous three days.
You can create up to three download tasks per day. The RAM users of an Alibaba Cloud account share the quota of the account.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
Action | String | Yes | CreateDownloadDataJob | The operation that you want to perform. Set the value to CreateDownloadDataJob. |
IotInstanceId | String | No | iot-cn-npk1u****** | 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 about instances, see Overview. |
TableName | String | Yes | product_info | The name of the table that you want to download. |
DownloadDataType | String | Yes | TABLE | The type of the object that you want to download. Set the value to TABLE. |
FileConfig | Map | No | {"fileName":"fileName01"} | The setting of the file. Specify a custom name for the fileName field. If you do not configure the fileName field, a file name is automatically generated. |
StartTime | Long | No | 1658332800000 | The beginning of the time range to query. |
EndTime | Long | No | 1658406464534 | The end of the time range to query. |
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 | 200 | The error code returned if the call fails. For more information about error codes, see Error codes. |
ErrorMessage | String | no authorization. | The error message returned if the call fails. |
RequestId | String | 4D6D7F71-1C94-4160-8511-EFF4B8F0643F | The ID of the request. |
Success | Boolean | true | Indicates whether the call was successful. Valid values:
|
Data | Object | The result that is returned. | |
Status | Integer | -1 | The status of the task. Valid values:
|
LongJobId | String | 62d949808bc742187xxxxxx | The ID of the download task. |
AsyncExecute | Boolean | true | Indicates whether the query is asynchronous. Valid values:
|
CsvUrl | String | https://oss-xxxx-xxxx.xxxx...... | The download link of the CSV file that is stored in an Object Storage Service (OSS) bucket. |
CsvFileName | String | test_download_file | The name of the downloaded file. |
Examples
Sample requests
http(s)://iot.cn-shanghai.aliyuncs.com/?Action=CreateDownloadDataJob
&IotInstanceId=iot-cn-npk1u******
&TableName=product_info
&DownloadDataType=TABLE
&StartTime=1658332800000
&EndTime=1658406464534
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateDownloadDataJobResponse>
<code>200</code>
<data>
<asyncExecute>true</asyncExecute>
<longJobId>62d949808bc742187xxxxxx</longJobId>
<resultDataInString/>
<status>-1</status>
</data>
<requestId>C8E9E92F-ADD1-1434-BA90-E85F70F5C536</requestId>
<success>true</success>
</CreateDownloadDataJobResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"code" : "200",
"data" : {
"asyncExecute" : true,
"longJobId" : "62d949808bc742187xxxxxx",
"resultDataInString" : "",
"status" : -1
},
"requestId" : "C8E9E92F-ADD1-1434-BA90-E85F70F5C536",
"success" : true
}
Error codes
HttpCode | Error code | Error message | Description |
400 | iot.dap.insight.noAuthorization | no authorization. | You do not have permissions to perform the operation. |
400 | iot.dap.insight.requestParamError | request param error. | The specified request parameter is invalid. |
400 | iot.dap.insight.serverError | server hsf error please try later | An error occurred in the backend High-speed Service Framework (HSF) service. Try again later. |
400 | iot.dap.insight.queryTimeMoreThanQueryDays | The query time range exceeded the allowed time range | The time range to query is invalid. |
400 | iot.dap.insight.processDownloadJobMoreConcurrenceCount | the number of concurrent download tasks in progress exceeds the upper limit | The number of download tasks that are concurrently running exceeds the limit. |
400 | iot.dap.insight.downloadTimesUpperLimit | the number of current job downloaded tasks exceeded the upper limit | The number of downloads for the download task on the current day exceeds the limit. |
400 | iot.dap.insight.downloadTaskNumUpperLimit | the number of downloaded tasks exceeded the upper limit | The number of download tasks that are executed on the current day exceeds the limit. |
For a list of error codes, see Service error codes.