Hi Guillaume Delafosse
I have done this before but is TDS because you can do this with a custom java action and a handler concept , The way of your java action failed because You must use Core.addRequestHandler() with a custom RequestHandler class to get access to the raw HttpServletRequestthat is the only reliable entry point for multipart parsing in Mendix.
if wanted I can give you step by step to implement the concept. I hope this helps
Hi,
Mendix does not natively support parsing multipart/form-data (mixed file + JSON) directly via standard Published REST services or HttpRequest objects. That’s why HttpRequest/content appears empty or unusable for this case.
To implement this correctly, you need to handle the request at a lower level.
1. Use a Custom Java Action
Handle the multipart request using HttpServletRequest:
HttpRequest as inputHttpServletRequest request = (HttpServletRequest) getContext().getHttpServletRequest();
Collection<Part> parts = request.getParts();
Then:
System.FileDocument2. Store file in Mendix
Create a FileDocument and store stream:
Core.storeFileDocumentContent(context, fileDoc, inputStream);
3. Parse metadata JSON
Core.deserializeJsonToObject() or import mappingHttpRequest.getContent() only works for raw bodies (JSON/XML), not multipartIf possible, split the API:
This avoids custom Java and is easier to maintain.
To support multipart/form-data with file + JSON in Mendix, you must use a custom Java action to parse HttpServletRequest parts, then manually store the file and process metadata. This is the standard and reliable approach.
Dear Guillaume,
I've implemented the same in my projects. Create form input as filedocument for file and form input as string for json. I've also written a blog on this Publishing multipart/form-data REST Service API in Mendix, thanks to your question.
Hope my answer helps. Reach me out for any queries.