Implementing an API receiving multipart/form-data

0
Hellomy objective is to implement an API in my Mendix Application that receives an multipart/form-data content type, with two parts : - file : the binary data of the file- metadata : a json for the file metadata (name, category, etc...)As a result my application could answer to this curl call : curl -F metada='{"category":"confidential"}' -F file=@myfile.pdf http://myapp.com/api/documents I tried to implement my API with a microflow that receieves HttpRequest as a paramater, my the HttpRequest/content attribute is empty, and I assume it won't support my form-data anyway because it's a String type value.I tried to implement a custom java function, and try to get the HttpServletRequest from the system.proxies.HttpRequest without any success.I noticed that my form-data is well transmitted to my Mendix app, because I saw it, with the two parts well filled, in an error message logged by the app.Has anyone implemented such feature?
asked
1 answers
1

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

answered