共用方式為


取得特定翻譯作業的狀態

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

  • get translation status使用方法來要求特定翻譯作業的狀態。 回應包含整體作業狀態,以及正在轉譯為該作業一部分的文件狀態。

要求 URL

重要

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

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

要求參數

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

查詢參數 必要 描述
id True 作業標識碼。

尋找 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 來自 Azure 入口網站 翻譯工具 服務 API 金鑰。 必要
Ocp-Apim-Subscription-Region 資源建立的所在區域。 使用美國西部等區域(地理)資源時需要。
& 項目符號。
Content-Type 承載的內容類型。 接受的值為 application/jsoncharset=UTF-8 必要

回應狀態代碼

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

狀態碼 描述
200 OK. 成功要求並傳回批次轉譯作業的狀態。 HeadersRetry-After: integerETag: string
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 字串 取得高階錯誤訊息。
目標 字串 取得錯誤的來源。 例如,對於無效的文件,這可能會是 documentsdocument id
innerError InnerTranslationError 符合 Azure AI 服務 API 指導方針的新內部錯誤格式。 此錯誤訊息包含必要的屬性 ErrorCode、訊息和選擇性屬性目標、details(索引鍵值組)、內部錯誤(可以是巢狀)。
innerError.code 字串 取得程式代碼錯誤字串。
innerError.message 字串 取得高階錯誤訊息。
innerError.target 字串 取得錯誤的來源。 例如,它會是 documentsdocument id 無效的檔。

範例

成功回應的範例

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

{
  "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 對像是錯誤回應的範例。 其他錯誤碼的架構相同。

狀態代碼:401

{
  "error": {
    "code": "Unauthorized",
    "message": "User is not authorized",
    "target": "Document",
    "innerError": {
      "code": "Unauthorized",
      "message": "Operation is not authorized"
    }
  }
}

下一步

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