参考
功能: Azure AI Translator →文档翻译
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 |
真 实 | 操作 ID。 |
查找 id
值
可以在 POST id
方法响应头 start-batch-translation
URL 值中查找作业 Operation-Location
。
/document/
参数后面的字母数字字符串是操作的作业 id
:
响应头 | 响应 URL |
---|---|
Operation-Location | {document-translation-endpoint}/translator/document/9dce0aa9-78dc-41ba-8cae-2e2f3c2ff8ec ?api-version=2024-05-01 |
- 还可以使用 get-translations-status 请求来检索翻译作业的列表及其 。
id
请求标头
请求标头为:
头文件 | 说明 | 条件 |
---|---|---|
Ocp-Apim-Subscription-Key | 来自 Azure 门户的 Translator 服务 API 密钥。 | 必需 |
Ocp-Apim-Subscription-Region | 创建资源的区域。 |
使用区域(地理)资源(如“中国北部”)时为必需。 &bullet. |
内容类型 | 有效负载的内容类型。 接受的值为 application/json 或 charset=UTF-8。 | 必需 |
响应状态代码
下面是请求可能返回的 HTTP 状态代码。
状态代码 | 说明 |
---|---|
200 | 没问题。 成功请求并返回批处理翻译操作的状态。 HeadersRetry-After: integerETag: string |
401 | 未授权。 检查凭据。 |
404 | 找不到资源。 |
500 | 内部服务器错误。 |
其他状态代码 | • 请求过多 • 服务器暂不可用 |
获取翻译状态响应
成功获取翻译状态响应
成功的响应中会返回以下信息。
名称 | 类型 | 说明 |
---|---|---|
id |
字符串 | 操作的 ID。 |
createdDateTimeUtc | 字符串 | 操作创建的日期时间。 |
lastActionDateTimeUtc | 字符串 | 操作状态发生更新的日期时间。 |
状态 | 字符串 | 作业或文档可能所处状态的列表: • 已取消 • 正在取消 • 失败 • NotStarted • 正在运行 • 已成功 • ValidationFailed |
摘要 | 状态摘要 | 摘要包含下面列出的详细信息。 |
summary.total | 整数 | 总计数。 |
summary.failed | 整数 | 失败计数。 |
summary.success | 整数 | 成功计数。 |
summary.inProgress | 整数 | 正在进行的作业计数。 |
summary.notYetStarted | 整数 | 尚未开始的作业计数。 |
summary.cancelled | 整数 | 已取消的作业计数。 |
summary.totalCharacterCharged | 整数 | API 计费的总字符数。 |
错误响应
名称 | 类型 | 说明 |
---|---|---|
代码 | 字符串 | 包含错误代码概要的枚举。 可能的值: • InternalServerError • InvalidArgument • InvalidRequest • RequestRateTooHigh • ResourceNotFound • ServiceUnavailable • 未授权 |
消息 | 字符串 | 获取概要错误消息。 |
目标 | 字符串 | 获取错误的源。 例如,对于无效文档,它为 documents 或 document id 。 |
innerError | InnerTranslationError | 符合 Azure AI 服务 API 准则的新的内部错误格式。 此错误消息包含必需的属性 ErrorCode、消息和可选属性目标、详细信息(键值对)、内部错误(可以嵌套)。 |
innerError.code | 字符串 | 获取代码错误字符串。 |
innerError.message | 字符串 | 获取概要错误消息。 |
innerError.target | 字符串 | 获取错误的源。 例如,对于无效文档,它为 documents 或 document 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"
}
}
}
后续步骤
按照快速入门详细了解如何使用文档翻译和客户端库。