你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

获取特定文档的状态

参考
功能:Azure AI 翻译 →文档翻译
API 版本:2024-05-01
HTTP 方法:GET

此方法返回作业中特定文档的状态,如请求 id 中由查询 documentId 参数指示。

请求 URL

重要

对文档翻译功能的所有 API 请求都需要位于Azure 门户的资源概述页上的自定义域终结点。

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

请求参数

查询字符串上传递的请求参数如下:

查询参数 必需 说明
documentId True 文档 ID。
id True 批 ID。

查找 iddocumentId

  • 可以在 POST start-batch-translation 方法响应标头 Operation-Location URL 值中找到作业id。 该 URL 的最后一个参数是操作的作业 id
响应头 结果 URL
Operation-Location {document-translation-endpoint}/translator/document/batches/{id}?api-version={date}/ 9dce0aa9-78dc-41ba-8cae-2e2f3c2ff8ec/
  • 还可以使用 GET 翻译状态 请求来检索查询字符串的作业 id 参数。

  • 可以在 documentId get-documents-status 方法响应中找到参数。

请求标头

请求标头为:

头文件 说明
Ocp-Apim-Subscription-Key 必需的请求标头

响应状态代码

下面是请求可能返回的 HTTP 状态代码。

状态代码 说明
200 没问题。 服务已接受的成功请求。 操作详细信息是 returned.HeadersRetry-After: integerETag: string
401 未授权。 检查凭据。
404 找不到该加密提供程序。 找不到资源。
500 内部服务器错误。
其他状态代码 • 请求过多
• 服务器暂不可用

获取文档状态响应

成功获取文档状态响应

名称 Type 描述
path string 文档或文件夹的位置。
sourcePath 字符串 源文档的位置。
createdDateTimeUtc 字符串 操作创建的日期时间。
lastActionDateTimeUtc string 操作状态发生更新的日期时间。
状态 字符串 作业或文档可能所处状态的列表:
• 已取消
• 正在取消
• 失败
• NotStarted
• 正在运行
• 已成功
• ValidationFailed
to string 目标语言的两个字母的语言代码。 查看语言列表
进度 数字 翻译进度(如果提供)
id 字符串 文档 ID。
characterCharged 整型 由 API 计费的字符。

错误响应

名称 Type 说明
code string 包含错误代码概要的枚举。 可能的值:
• InternalServerError
• InvalidArgument
• InvalidRequest
• RequestRateTooHigh
• ResourceNotFound
• ServiceUnavailable
• 未授权
message 字符串 获取概要错误消息。
innerError InnerTranslationError 符合 Azure AI 服务 API 准则的新的内部错误格式。 此错误消息包含必需的属性 ErrorCode、消息和可选属性目标、详细信息(键值对)、内部错误(可以嵌套)。
innerError.code 字符串 获取代码错误字符串。
innerError.message 字符串 获取概要错误消息。
innerError.target string 获取错误的源。 例如,对于单个文档,它为 documentsdocument id

示例

成功响应示例

以下 JSON 对象是成功响应的示例。

{
  "path": "https://myblob.blob.core.windows.net/destinationContainer/fr/mydoc.txt",
  "sourcePath": "https://myblob.blob.core.windows.net/sourceContainer/fr/mydoc.txt",
  "createdDateTimeUtc": "2020-03-26T00:00:00Z",
  "lastActionDateTimeUtc": "2020-03-26T01:00:00Z",
  "status": "Running",
  "to": "fr",
  "progress": 0.1,
  "id": "273622bd-835c-4946-9798-fd8f19f6bbf2",
  "characterCharged": 0
}

错误响应示例

以下 JSON 对象是错误响应的示例。 其他错误代码的架构相同。

状态代码:401

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

后续步骤

遵循快速入门,详细了解如何使用文档翻译和客户端库。