簡介
本文以您的 API 集合設定為基礎,說明如何使用 Workiva API 從 Workiva 匯出檔案。本指南適用於匯出:
- 文件格式為 .PDF、 .DOCX或 .XHTML
- 試算表格式為 .XLSX、 .PDF或 .CSV
- 簡報格式為 .PDF 或 .PPTX
我們還提供了一個額外選項,用於以 .tar.gz 格式匯出 Workiva 原生檔案。
必要條件
繼續之前,請確保您已完成 將 Workiva API 集合匯入 Postman 指南中的所有步驟。
驗證
- 開啟 Postman 工作區,並確保已選取正確的環境。
-
展開 IAM Services 集合,開啟 OAuth2 資料夾,然後選擇 Retrieve a token。
- 按一下 傳送 以產生驗證權杖。權杖會自動儲存在 {{access_token}} 環境變數中,供所有後續要求使用。
注意: 存取權杖會在 600 秒(10 分鐘)後過期。一旦過期,請重複此步驟以產生新的 Token。
啟動檔案匯出(文件、簡報、試算表)
此範例著重於將 Workiva 文件匯出為 .PDF、 .DOCX或 .XHTML。匯出 試算表 或 簡報時也適用相同的概念。
- 展開 Platform API 集合併導覽至 Documents → Document ID → Export。
- 開啟 啟動文件匯出 要求。
- 在 參數 索引標籤中,輸入 documentId。
- 更新要求主體以指定 匯出格式:
-
{ "pdfOptions": { "includeAlternateRowFill": true、" includeAttachmentLabels":true、" includeComments":true、" includeDraft Watermark":true、" includeHyperlinks":true、" includeLeaderDots":true、" includeTrackChanges":true、"tagForWebAccessibility ": true、"useCmykColorspace": true }、"format": "pdf"、"sections": [] } -
{ "docxOptions": { "includeLeaderDots": true, "showTableCellShading": true }, "format": "docx", "sections": [] } -
{ "xhtmlOptions": { "editableSimple": true, "editableXhtml": false, "includeExternalHyperlinks": false, "includeHeadersAndFooters": false }, "format": "xhtml", "sections": [] }
-
- 傳送要求以啟動匯出。此過程包括三個步驟:
-
傳送 POST 要求。回應包含
Location標頭,而標頭則包含 URL。 -
處理完成後,向
位置標頭中的 URL 發出 GET 請求,以檢查匯出狀態並擷取 資源 URL 。 -
使用 資源 URL 發出最終 GET 要求,以下載匯出的檔案。
-
匯出的檔案可能會以二進位資料形式傳回。這是預期的行為。只需使用適當的擴展名 (例如 .pdf、 .docx或 .xhtml) 儲存檔案。
接下來,檢閱如何使用 API 集合 [ ] 匯入檔案。