調用介面建立資料下載任務。
使用說明
- 該任務等同於在控制台建立的資料下載任務,使用者可在對應資料表的匯出管理頁面查看此次下載任務的日誌,並下載檔案。
- 通過該介面建立下載任務會增加AMQP訊息推送,其中
consumerGroupId請選用dop_aliyun_group_name,訊息內容包含此次下載任務的執行狀態,使用者可根據此狀態,配合GetDownloadFile介面擷取檔案下載地址或查看下載任務的異常資訊。
使用限制
- 同一資料執行個體下,每次只能建立1個下載任務。待上一個任務執行完成後才能建立新的下載任務,否則會提示超過下載任務數限制異常。
- 單次下載資料時間範圍最多為3天。
- 1天內只能建立3個下載任務,RAM使用者共用阿里雲帳號配額。
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
請求參數
| 名稱 | 類型 | 是否必選 | 樣本值 | 描述 |
| Action | String | 是 | CreateDownloadDataJob | 系統規定參數。取值:CreateDownloadDataJob。 |
| IotInstanceId | String | 否 | iot-cn-npk1u****** | 執行個體ID。您可在物聯網平台控制台的執行個體概覽頁面,查看當前執行個體的ID。 重要
執行個體的更多資訊,請參見執行個體概述。 |
| TableName | String | 是 | product_info | 需下載的表名稱。 |
| DownloadDataType | String | 是 | TABLE | 下載對象的類型,暫只支援TABLE。 |
| FileConfig | Map | 否 | {"fileName":"fileName01"} | 下載檔案設定。給下載檔案設定一個名稱(fileName),可自訂,若fileName不傳則預設產生一個檔案名稱。 |
| StartTime | Long | 否 | 1658332800000 | 時間範圍,查詢資料的開始時間。 |
| EndTime | Long | 否 | 1658406464534 | 時間範圍,查詢資料的結束時間。 |
調用API時,除了本文介紹的該API的特有請求參數,還需傳入公用請求參數。公用請求參數說明,請參見公用參數文檔。
返回資料
| 名稱 | 類型 | 樣本值 | 描述 |
| Code | String | 200 | 調用失敗時,返回的錯誤碼。更多資訊,請參見錯誤碼。 |
| ErrorMessage | String | no authorization. | 調用失敗時,返回的錯誤資訊。 |
| RequestId | String | 4D6D7F71-1C94-4160-8511-EFF4B8F0643F | 請求ID,阿里雲為該請求產生的唯一識別碼。 |
| Success | Boolean | true | 是否調用成功。
|
| Data | Object | 請求的返回結果。 |
|
| Status | Integer | -1 | 下載任務的執行狀態。
|
| LongJobId | String | 62d949808bc742187xxxxxx | 下載任務的ID。 |
| AsyncExecute | Boolean | true | 是否是非同步查詢。
|
| CsvUrl | String | https://oss-xxxx-xxxx.xxxx...... | OSS檔案的下載地址。 |
| CsvFileName | String | test_download_file | 下載檔案的名稱。 |
樣本
請求樣本
http(s)://iot.cn-shanghai.aliyuncs.com/?Action=CreateDownloadDataJob
&IotInstanceId=iot-cn-npk1u******
&TableName=product_info
&DownloadDataType=TABLE
&StartTime=1658332800000
&EndTime=1658406464534
&公用請求參數
正常返回樣本
XML格式
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格式
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
}
錯誤碼
| HttpCode | 錯誤碼 | 錯誤資訊 | 描述 |
| 400 | iot.dap.insight.noAuthorization | no authorization. | 此操作沒有許可權 |
| 400 | iot.dap.insight.requestParamError | request param error. | 請求參數異常。 |
| 400 | iot.dap.insight.serverError | server hsf error please try later | 後端HSF服務錯誤,請稍後重試 |
| 400 | iot.dap.insight.queryTimeMoreThanQueryDays | The query time range exceeded the allowed time range | 查詢的時間範圍超出允許的時間範圍 |
| 400 | iot.dap.insight.processDownloadJobMoreConcurrenceCount | the number of concurrent download tasks in progress exceeds the upper limit | 當前運行中的下載任務超過規定的最大並發數 |
| 400 | iot.dap.insight.downloadTimesUpperLimit | the number of current job downloaded tasks exceeded the upper limit | 當前任務當天下載次數超過上限 |
| 400 | iot.dap.insight.downloadTaskNumUpperLimit | the number of downloaded tasks exceeded the upper limit | 當天啟動並執行下載任務超過上限 |
訪問錯誤中心查看更多錯誤碼。