I’m integrating our incident management system with Arena QMS API and running into issues with file attachment uploads. The API endpoint accepts multipart form data but my uploads consistently fail with 400 Bad Request errors.
I’ve verified the Content-Type headers are set correctly and I’m using the standard file parameter naming from the documentation. My HTTP client library (Apache HttpClient) successfully uploads to other endpoints, so I suspect there’s something specific about how Arena handles multipart form data encoding.
HttpPost post = new HttpPost(apiUrl + "/incidents/" + incidentId + "/attachments");
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addBinaryBody("file", fileBytes, ContentType.APPLICATION_OCTET_STREAM, fileName);
post.setEntity(builder.build());
The error response doesn’t provide much detail beyond “Invalid request format”. Has anyone successfully implemented attachment uploads to the incident management API? What am I missing in the multipart encoding?
Check your file size limits and MIME type validation. Arena has default limits around 10MB per attachment and only accepts specific MIME types depending on your configuration. If you’re uploading larger files or uncommon formats, that could trigger the 400 error. The API should return more specific error codes, but I’ve seen cases where misconfigured MIME type filters just return generic bad request responses.
I ran into the same issue last month. Arena’s multipart implementation is stricter than most APIs. The key is setting the boundary parameter explicitly in your Content-Type header and ensuring your file parameter name matches exactly what the API expects (case-sensitive). Also check if you’re including the required metadata fields like ‘description’ or ‘documentType’ in the multipart request - these are often mandatory even if not obvious from the docs.
One thing that caught me was the charset encoding in the Content-Type. Arena expects UTF-8 explicitly declared. Try adding charset=UTF-8 to your multipart boundary declaration. Also, make sure you’re not accidentally double-encoding the filename if it contains special characters.
The documentation doesn’t make this clear enough, but there are multiple required fields in the multipart request beyond just the file itself. You need to include metadata as separate form fields, not just as part of the file upload.
Here’s what worked for me addressing all the key aspects:
Multipart Form Data Structure:
Arena expects each piece of metadata as a separate text/plain part before the file part. The order matters - metadata first, then file.
Content-Type Headers:
The main request must have Content-Type: multipart/form-data with an explicit boundary. Each part needs its own Content-Disposition with proper name attributes.
File Parameter Naming:
Use ‘attachment’ not ‘file’ as the parameter name. This is case-sensitive and not well documented.
HTTP Client Configuration:
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
builder.addTextBody("description", "Incident evidence", ContentType.TEXT_PLAIN);
builder.addTextBody("documentType", "EVIDENCE", ContentType.TEXT_PLAIN);
builder.addBinaryBody("attachment", fileBytes, ContentType.create(mimeType), fileName);
The BROWSER_COMPATIBLE mode is crucial - it formats the multipart data exactly how Arena expects it. Also ensure your HttpClient has a timeout of at least 60 seconds for larger files. I tested this with Apache HttpClient 4.5.13 and it works reliably once you have all these pieces correct.
For debugging, enable wire logging in HttpClient to see the exact bytes being sent. Compare against a successful Postman request using the same endpoint.