Share via


取得支援的檔案格式

參考
服務:Azure AI 文件翻譯
API 版本:1.1 版

取得支援的文件格式方法會傳回文件翻譯服務所支援的文件格式清單。 此清單包含通用擴展名,如果使用上傳 API,則為內容類型。

要求 URL

GET 要求傳送至:

GET https://<NAME-OF-YOUR-RESOURCE>.cognitiveservices.azure.com/translator/text/batch/v1.1/documents/formats

瞭解如何尋找您的 自定義功能變數名稱

重要

  • 對文件翻譯服務的所有 API 要求都需要自定義網域端點
  • 您無法使用 Azure 入口網站 資源金鑰和端點頁面上找到的端點,也無法使用全域翻譯工具端點,api.cognitive.microsofttranslator.com以對文件翻譯提出 HTTP 要求。

要求標頭

要求標頭如下:

標頭 描述
Ocp-Apim-Subscription-Key 必要要求標頭

回應狀態代碼

以下是要求傳回的可能 HTTP 狀態代碼。

狀態碼 描述
200 OK. 傳回支援的檔案檔案格式清單。
500 內部伺服器錯誤。
其他狀態代碼 • 要求太多
• 伺服器暫時無法使用

檔案格式回應

成功的 fileFormatListResult 回應

成功回應中會傳回下列資訊。

名稱 類型​​ 描述
value FileFormat [] FileFormat[] 包含列出的詳細資料。
value.contentTypes string[] 此格式支援的內容類型。
value.defaultVersion string 如果未指定任何版本,則為預設版本。
value.fileExtensions string[] 此格式支援的擴展名。
value.format string 格式的名稱。
value.versions string [] 支援的版本。

回覆錯誤

名稱 類型​​ 描述
code string 包含高階錯誤碼的列舉。 可能的值:• InternalServerError
• InvalidArgument
• InvalidRequest
• RequestRateTooHigh
• ResourceNotFound
• ServiceUnavailable
•未經授權
message string 取得高階錯誤訊息。
innerError InnerTranslationError 符合 Azure AI 服務 API 指導方針的新內部錯誤格式。 此錯誤訊息包含必要的屬性 ErrorCode、訊息和選擇性屬性目標、details(索引鍵值組)、內部錯誤(可以是巢狀)。
innerError.code string 取得程式代碼錯誤字串。
innerError.message string 取得高階錯誤訊息。
innerError.target string 取得錯誤的來源。 例如,對於無效的文件,這可能會是 documentsdocument 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"
    }
  }
}

下一步

請遵循我們的快速入門,深入瞭解如何使用文件翻譯和客戶端連結庫。