We’re building a document ingestion pipeline for Agile 9.3.6 and consistently getting HTTP 415 ‘Unsupported Media Type’ when uploading PDF files via the document management API. The documentation says it supports PDF, but our POST requests are being rejected.
Request headers:
Content-Type: application/pdf
POST /api/v1/documents/{docId}/files
The API accepts the document metadata creation fine, but fails when we try to attach the actual file. We’ve tried various MIME type configurations and multipart form approaches without success. Has anyone successfully implemented PDF uploads through the doc-mgmt API? What’s the correct content type and request format?
I’ve implemented this successfully. One gotcha: the API is very particular about the Content-Disposition header format in the multipart section. You need to include both the field name and the filename parameter. If the filename extension doesn’t match the Content-Type you’re declaring, Agile will reject it. So if you’re uploading a PDF, make sure the filename ends with .pdf and the Content-Type for that part is application/pdf.
The document upload API requires multipart/form-data encoding, not direct application/pdf. You can’t just POST the binary content with a PDF content type. You need to structure it as a multipart request with the file as one part and metadata as another. The Content-Type header for the overall request should be multipart/form-data with a boundary parameter.
The field name should be ‘file’ in the multipart form. You don’t need to resend the document metadata - that’s already associated with the document ID in your URL path. Just send the file part with the correct filename in the Content-Disposition header. Make sure your multipart boundary is properly formatted and matches between the Content-Type header and the body separators.
Also check your Agile server’s MIME type configuration. The allowed file types are defined server-side in the Agile settings. Even if you send the correct multipart format, if PDF isn’t in the allowed MIME types list, you’ll get the 415 error. Admin can check this in Java Client under Admin > Server Settings > File Manager > Allowed File Types. Make sure application/pdf is listed there.
I’ve confirmed PDF is in the allowed file types list on the server. Now working on converting our request to multipart/form-data. Do I need to send the document metadata again in the file upload request, or is it just the file part? And what should the field name be for the file in the multipart form - ‘file’, ‘attachment’, or something else specific to Agile?