Single and Multiple Document Generation Aren't the Same Endpoint With an Array Bolted On
说明与用途
开发者错误地使用单文档端点批量生成文档,导致错误。切换到专用的 Generate Documents (Multiple) 端点并使用正确的请求和响应结构,可一次性处理多条记录,返回包含文件的 JSON 数组。
问题
Developers assume batch document generation can be done by adding an array to the single-document endpoint, but the PDF4me API requires a distinct endpoint with different input and output requirements.
结果
Switching to the correct batch endpoint eliminates 404 errors, supports batch data formats, and provides a structured JSON response with per-file metadata, enabling automated handling of multiple documents.
工作流
- 1. Identify the correct endpoint: POST /api/v2/GenerateDocumentMultiple
- 2. Prepare payload with templateFileType (Docx, HTML, PDF), templateFileName, templateFileData, documentDataType (Json or XML), and documentDataText as an array of records
- 3. Set outputType (PDF, Docx, or optional xlsx for Docx/PDF templates)
- 4. Send POST request with Authorization header
- 5. Parse JSON response: iterate over outputDocuments array, extract fileName and base64 streamFile (or fileContent/content/data)
- 6. Decode base64 and write each file to disk or further processing
证据
Generate Documents (Multiple) is a separate endpoint, with a narrower set of accepted inputs, one output format Single cannot touch at all, and a response envelope shaped nothing like the one Single returns.
Single lives at POST /api/v2/GenerateDocumentSingle. The batch version, despite its own docs page being titled "Generate Documents (Multiple)", lives at POST /api/v2/GenerateDocumentMultiple, singular Document, no trailing s.
- 记录日期: 2026-09-15T10:45:57.055Z