Asynchronously translate Contacts IDs
API call description
- Construct the document to be translated, as shown in the following figure.
Note
Only files in xlsx, xls, csv, and txt formats are supported.- Call the Single-step file upload API to obtain the media_id.
- Call this API to obtain the translation job ID.
Note
After this API is called, if the file is translated successfully, an asynchronous job callback notification is triggered. 4. Call the Obtain the results of an asynchronous translation task API to obtain the download link of the translated file.Note
It is recommended to reference the returned file download link with the<a> tag. Do not specify the download attribute (due to browser compatibility issues).
5. The file content downloaded by the user is shown in the following figure.
When calling this API, you may encounter the following issue:
- Issue: An
excelfile generated with theNodeJsthird-party libraryexceljslooks fine in content, but the translation fails. - Cause: When
sharedStringis not enabled,exceljswrites file content usingformula stringby default. This behavior is non-standard and causes translation to fail. - Solution: Refer to the
exceljsdocumentation and force-enable theuseSharedStringsoption.
Request
Basic information
| Field | Value |
|---|---|
| HTTP URL | https://api.dingtalk.io/v1.0/contact/files/translate |
| HTTP Method | POST |
| Supported app types | appType-Third-party enterprise app |
| Permission requirement | permission-qyapi_get_member-User information read permission |
Request header
| Name | Type | Required | Description |
|---|---|---|---|
| x-acs-dingtalk-access-token | String | Yes | The access credential for calling this API. Obtain it by calling the Obtain the access token of the enterprise authorized to a third-party app API. |
Request body
| Name | Type | Required | Description |
|---|---|---|---|
| medias | Map<String, String> | Yes | The information about the files to be translated. - A Map type. The key is the Drive file media_id, which is obtained by calling the Obtain file upload information API. - The value is the file name, which must include the file extension and be consistent with the file name passed in when calling the Obtain file upload information API. - Only files in xlsx, xls, csv, and txt formats are supported. - A maximum of 20 files. |
| outputFileName | String | No | The name of the packaged file after translation. Do not include a file extension. This parameter is required if more than one file is specified in medias. |
| unionId | String | Yes | The unionId of the user who currently exports the document. Obtain it by calling the Obtain user information by silent login code API. |
Request example
HTTPResponse
Response body
| Name | Type | Description |
|---|---|---|
| jobId | String | The asynchronous translation job ID. Maximum length: 64 characters. jobId is used as input for the Obtain the results of an asynchronous translation task API. |
Response body example
Error codes
If an error is returned when calling this API, look up the error message in the Global error codes document for a solution.| HttpCode | Error code | Error message | Description |
|---|---|---|---|
| 400 | param.invalid | %s | Invalid parameter |
| 500 | system.busy | System busy | System busy |