文档

CreateDocTranslateTask - 创建文档翻译任务

更新时间:

创建文档翻译任务。

接口说明

说明 仅支持通过 POST 方式调用

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

授权信息

当前API暂无授权信息透出。

请求参数

名称类型必填描述示例值
SourceLanguagestring

原文语言,语言 code 参考

en
TargetLanguagestring

目标语言,语言 code 参考

zh
FileUrlstring

文档 URL。

http://fileUrl
Scenestring

场景,支持:通用(general)、商品标题(title)、商品详情(description)、买卖家沟通(message)、医疗(medical)、社交(social)、科技(tech)。

general
CallbackUrlstring

翻译结果回调 URL,服务器会向回调地址发起 post 请求

请求 body

raw json

  • 参数名 说明

  • task_id 任务 id

  • status 状态

  • errCode 错误码

  • errMsg 错误信息

  • translateFileUrl 文件下载地址,过期时间 1 小时

IP 白名单

59.82.61.52

203.119.241.30

203.119.241.98

59.82.84.90

203.119.241.56

59.82.61.75

回调服务示例:该服务用于回调方式获取翻译结果

import com.alibaba.fastjson.JSON;

import com.alibaba.fastjson.JSONObject;

import org.springframework.web.bind.annotation.RequestBody;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;

import org.springframework.web.bind.annotation.RestController;

@RestController

public class CallbackController {

    @RequestMapping(value = "callback", method = RequestMethod.POST)

    public void callback(@RequestBody String body) {

        try {

            JSONObject result = JSON.parseObject(body);

            if (200 != result.getInteger("errCode")) {

                System.out.println("fail " + result.getString("erMsg"));

                return;

            }

            System.out.println("task_id:" + result.getString("task_id"));

            System.out.println("status:" + result.getString("status"));

            System.out.println("translateFileUrl:" + result.getString("translateFileUrl"));

        } catch (Exception e) {

            e.printStackTrace();

        }

    }

}
http://callbackUrl
ClientTokenstring

提供幂等能力,3 分钟内,相同的值只会生效一次。

token

返回参数

名称类型描述示例值
object
Statusstring

任务状态。

ready
RequestIdstring

请求 ID。

D3920BC3-A395-4CAD-9E84-7C39EB07507B
TaskIdstring

任务 ID。

0586df512c8b4bb382d7d9a6a01b5854

示例

正常返回示例

JSON格式

{
  "Status": "ready",
  "RequestId": "D3920BC3-A395-4CAD-9E84-7C39EB07507B",
  "TaskId": "0586df512c8b4bb382d7d9a6a01b5854"
}

错误码

HTTP status code错误码错误信息描述
10910009子账号没有权限-
11010010账号没有开通服务-
11110011子账号服务失败-
11210012翻译服务调用失败-
11310013账号服务没有开通或者欠费-
19919999An unknown error occurred.未知异常
40010021The parameter is invalid.参数无效。
40010022The parameter fileUrl is invalid.参数fileUrl非法。
40010023The parameter fileUrl is not accessible.参数fileUrl无法访问。
40010024The parameter callbackUrl is invalid.参数callbackUrl非法。
40010030The file size exceeds the limit.文件大小超过了限制。
40010031The specified file type is invalid.文件类型不支持。
400InvalidAccountStatusThe Machine Translation service has not been activated.用户未开通机器翻译服务。
40310029The number of calls per day exceeds the limit.超出单日调用次数限制。

访问错误中心查看更多错误码。

变更历史

变更时间变更内容概要操作
暂无变更历史
  • 本页导读 (0)
文档反馈