共用方式為


取消翻譯

參考
功能:Azure AI 翻譯工具 → 檔翻譯
API 版本:2024-05-01
HTTP 方法:DELETE

  • 這個方法會取消目前處理或已排入佇列的翻譯作業,如查詢參數在要求 id 中所指出。
  • 如果作業已完成、失敗或仍取消,則不會取消。 在這些情況下,會傳回不正確的要求。
  • 無法取消已完成的翻譯,並收取費用。

要求 URL

重要

檔翻譯功能的所有 API 要求都需要位於 Azure 入口網站 資源概觀頁面上的自定義網域端點。

  curl -i -X  DELETE "{document-translation-endpoint}/translator/document/batches/{id}?api-version={date}"

要求參數

在查詢字串上傳遞的要求參數如下:

查詢參數 必要 描述
id True operation-ID。

尋找 id

您可以在 POST start-batch-translation 方法回應標頭 Operation-Location URL 值中找到作業id。 參數後面的 /document/ 英數位元字串是作業的 作業 id

回應標頭 回應 URL
Operation-Location {document-translation-endpoint}/translator/document/9dce0aa9-78dc-41ba-8cae-2e2f3c2ff8ec?api-version=2024-05-01

要求標頭

要求標頭如下:

標題 描述
Ocp-Apim-Subscription-Key 必要要求標頭

回應狀態代碼

以下是要求傳回的可能 HTTP 狀態碼。

狀態碼 描述
200 OK. 取消提交的要求
401 未經授權。 檢查您的認證。
404 找不到。 找不到資源。
500 內部伺服器錯誤。
其他狀態碼 • 要求太多
• 伺服器暫時無法使用

取消翻譯回應

成功回應

成功回應中會傳回下列資訊。

名稱 類型​​ 描述
id 字串 作業的標識碼。
createdDateTimeUtc 字串 作業已建立日期時間。
lastActionDateTimeUtc 字串 更新作業狀態的日期時間。
status String 作業或檔案可能的狀態清單:• 已取消
•取消
•失敗
• NotStarted
•運行
•成功
• ValidationFailed
摘要 StatusSummary 包含詳細數據清單的摘要。
summary.total 整數 檔總數。
summary.failed 整數 檔計數失敗。
summary.success 整數 已成功翻譯的檔計數。
summary.inProgress 整數 進行中的檔計數。
summary.notYetStarted 整數 尚未開始處理的檔計數。
summary.cancelled 整數 已取消的數目。
summary.totalCharacterCharged 整數 API 收費的字元總數。

回覆錯誤

名稱 類型​​ 描述
code 字串 包含高階錯誤碼的列舉。 可能的值:
• InternalServerError
• InvalidArgument
• InvalidRequest
• RequestRateTooHigh
• ResourceNotFound
• ServiceUnavailable
•未經授權
message 字串 取得高階錯誤訊息。
目標 字串 取得錯誤的來源。 例如,它會是「檔」或 document id 無效的檔。
innerError InnerTranslationError 符合 Azure AI 服務 API 指導方針的新內部錯誤格式。 此錯誤訊息包含必要屬性 ErrorCode、訊息和選擇性屬性目標、詳細資料 ( 機碼值組)、內部錯誤 (可為巢狀)。
innerError.code 字串 取得程式代碼錯誤字串。
innerError.message 字串 取得高階錯誤訊息。
innerError.target 字串 取得錯誤的來源。 例如,如果有無效文件,其會是 documentsdocument id

範例

成功回應的範例

下列 JSON 對像是成功的回應範例。

狀態碼:200

{
  "id": "727bf148-f327-47a0-9481-abae6362f11e",
  "createdDateTimeUtc": "2020-03-26T00:00:00Z",
  "lastActionDateTimeUtc": "2020-03-26T01:00:00Z",
  "status": "Succeeded",
  "summary": {
    "total": 10,
    "failed": 1,
    "success": 9,
    "inProgress": 0,
    "notYetStarted": 0,
    "cancelled": 0,
    "totalCharacterCharged": 0
  }
}

範例錯誤回應

下列 JSON 對像是錯誤回應的範例。 其他錯誤碼的架構相同。

狀態代碼:500

{
  "error": {
    "code": "InternalServerError",
    "message": "Internal Server Error",
    "target": "Operation",
    "innerError": {
      "code": "InternalServerError",
      "message": "Unexpected internal server error has occurred"
    }
  }
}

下一步

請遵循我們的快速入門,深入瞭解如何使用文件翻譯和客戶端連結庫。