获取支持的文档格式

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

此方法返回文档翻译功能支持的文档格式列表。 如果使用上传 API,则列表中包含常见的文件扩展名和 content-type。

请求网址

Important

所有针对文档翻译功能的 API 请求都需要使用您在 Azure 门户资源概述页面上看到的自定义域终结点。

 curl -i -X GET "{document-translation-endpoint}/translator/document/formats?api-version={date}&type=document"

请求标头

请求标头为:

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

响应状态代码

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

状态代码 说明
200 OK. 返回受支持文件格式的列表。
500 内部服务器错误。
其他状态代码 • 请求过多
• 服务器暂不可用

文件格式响应

成功的 fileFormatListResult 响应

成功的响应中会返回以下信息。

Name 类型 说明
value FileFormat [] FileFormat[] 包含列出的详细信息。
value.contentTypes string[] 此格式支持的内容类型。
value.defaultVersion 字符串 如果未指定任何版本,则为默认版本。
value.fileExtensions string[] 此格式支持的文件扩展名。
value.format 字符串 格式的名称。
value.versions string [] 支持的版本。

错误响应

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

示例

成功响应示例

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

状态代码:200

{
    "value": [
        {
            "format": "PlainText",
            "fileExtensions": [
                ".txt"
            ],
            "contentTypes": [
                "text/plain"
            ],
            "versions": []
        },
        {
            "format": "OpenXmlWord",
            "fileExtensions": [
                ".docx"
            ],
            "contentTypes": [
                "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
            ],
            "versions": []
        },
        {
            "format": "OpenXmlPresentation",
            "fileExtensions": [
                ".pptx"
            ],
            "contentTypes": [
                "application/vnd.openxmlformats-officedocument.presentationml.presentation"
            ],
            "versions": []
        },
        {
            "format": "OpenXmlSpreadsheet",
            "fileExtensions": [
                ".xlsx"
            ],
            "contentTypes": [
                "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
            ],
            "versions": []
        },
        {
            "format": "OutlookMailMessage",
            "fileExtensions": [
                ".msg"
            ],
            "contentTypes": [
                "application/vnd.ms-outlook"
            ],
            "versions": []
        },
        {
            "format": "HtmlFile",
            "fileExtensions": [
                ".html",
                ".htm"
            ],
            "contentTypes": [
                "text/html"
            ],
            "versions": []
        },
        {
            "format": "PortableDocumentFormat",
            "fileExtensions": [
                ".pdf"
            ],
            "contentTypes": [
                "application/pdf"
            ],
            "versions": []
        },
        {
            "format": "XLIFF",
            "fileExtensions": [
                ".xlf"
            ],
            "contentTypes": [
                "application/xliff+xml"
            ],
            "versions": [
                "1.0",
                "1.1",
                "1.2"
            ]
        },
        {
            "format": "TSV",
            "fileExtensions": [
                ".tsv",
                ".tab"
            ],
            "contentTypes": [
                "text/tab-separated-values"
            ],
            "versions": []
        },
        {
            "format": "CSV",
            "fileExtensions": [
                ".csv"
            ],
            "contentTypes": [
                "text/csv"
            ],
            "versions": []
        },
        {
            "format": "RichTextFormat",
            "fileExtensions": [
                ".rtf"
            ],
            "contentTypes": [
                "application/rtf"
            ],
            "versions": []
        },
        {
            "format": "WordDocument",
            "fileExtensions": [
                ".doc"
            ],
            "contentTypes": [
                "application/msword"
            ],
            "versions": []
        },
        {
            "format": "PowerpointPresentation",
            "fileExtensions": [
                ".ppt"
            ],
            "contentTypes": [
                "application/vnd.ms-powerpoint"
            ],
            "versions": []
        },
        {
            "format": "ExcelSpreadsheet",
            "fileExtensions": [
                ".xls"
            ],
            "contentTypes": [
                "application/vnd.ms-excel"
            ],
            "versions": []
        },
        {
            "format": "OpenDocumentText",
            "fileExtensions": [
                ".odt"
            ],
            "contentTypes": [
                "application/vnd.oasis.opendocument.text"
            ],
            "versions": []
        },
        {
            "format": "OpenDocumentPresentation",
            "fileExtensions": [
                ".odp"
            ],
            "contentTypes": [
                "application/vnd.oasis.opendocument.presentation"
            ],
            "versions": []
        },
        {
            "format": "OpenDocumentSpreadsheet",
            "fileExtensions": [
                ".ods"
            ],
            "contentTypes": [
                "application/vnd.oasis.opendocument.spreadsheet"
            ],
            "versions": []
        },
        {
            "format": "Markdown",
            "fileExtensions": [
                ".markdown",
                ".mdown",
                ".mkdn",
                ".md",
                ".mkd",
                ".mdwn",
                ".mdtxt",
                ".mdtext",
                ".rmd"
            ],
            "contentTypes": [
                "text/markdown",
                "text/x-markdown",
                "text/plain"
            ],
            "versions": []
        },
        {
            "format": "Mhtml",
            "fileExtensions": [
                ".mhtml",
                ".mht"
            ],
            "contentTypes": [
                "message/rfc822",
                "application/x-mimearchive",
                "multipart/related"
            ],
            "versions": []
        }
    ]
}

错误响应示例

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

状态代码:500

{
  "error": {
    "code": "InternalServerError",
    "message": "Internal Server Error",
    "innerError": {
      "code": "InternalServerError",
      "message": "Unexpected internal server error has occurred"
    }
  }
}

后续步骤

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