CreateDocTranslateTask

更新时间:
复制 MD 格式

Creates a document translation task.

Operation description

Note

This operation supports only POST requests.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

alimt:CreateDocTranslateTask

create

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

SourceLanguage

string

Yes

The source language. For more information, see Language codes.

en

TargetLanguage

string

Yes

The target language. For more information, see Language codes.

zh

FileUrl

string

Yes

The URL of the document.

http://fileUrl

Scene

string

No

The scenario. Valid values: `general`, `title` (product titles), `description` (product descriptions), `message` (buyer-seller communication), `medical`, `social`, and `tech`.

general

CallbackUrl

string

No

The webhook address for the translation result. The server sends a POST request to this address.

Request body

Raw JSON

  • Parameter Description

  • task_id: The task ID.

  • status: The task status.

  • errCode: The error code.

  • errMsg: The error message.

  • translateFileUrl: The URL to download the translated file. The URL is valid for 1 hour.

IP address whitelist

59.82.61.52

203.119.241.30

203.119.241.98

59.82.84.90

203.119.241.56

59.82.61.75

Sample callback service: This service is used to receive the translation result through a callback.

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("errMsg"));

                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

ClientToken

string

No

Ensures idempotence. A request with the same client token is processed only once within 3 minutes.

token

Response elements

Element

Type

Description

Example

object

Status

string

The status of the task.

ready

RequestId

string

The request ID.

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

TaskId

string

The task ID.

0586df512c8b4bb382d7d9a6a01b5854

Examples

Success response

JSON format

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

Error codes

HTTP status code

Error code

Error message

Description

110 10010 The account has not activated the service.
111 10011 Sub-account service failed.
199 19999 An unknown error occurred.
112 10012 Failed to call the translation service.
113 10013 The account service is not enabled or has overdue payments.
400 10021 The parameter is invalid.
400 10022 The parameter fileUrl is invalid.
400 10023 The parameter fileUrl is not accessible.
400 10024 The parameter callbackUrl is invalid. The parameter callbackUrl is invalid.
400 10031 The specified file type is invalid. The type of file is not valid.
400 InvalidAccountStatus The Machine Translation service has not been activated. The Machine Translation service has not been activated.
400 RepeatInvoke Repeated calls. Repeated calls
403 10029 The number of calls per day exceeds the limit. The number of calls per day limit exceeded.
109 10009 The sub-account does not have permission.
429 REQUESTS.OVER.LIMIT The request is too frequent, please try again later. Request too frequent, please try again later

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.