Multipart File upload with rest API call

1
Hi, i am doing multipart file upload using file manager in mendix. Actually i dont know Is there a way to do that by normal consume rest service action If Yes how to do that Actually i seen that we cant do that simply like that we have to use Rest Service Module So i have imported this Rest service module from Appstore But i cant able to use that. So anyone help with the steps to use that rest service module for multipart file upload to API Thanks in advance
asked
7 answers
5

Native REST in Mx7 does not (yet) support multipart FormData 

1. Download the REST service module from the appstore

2. Add JavaAction call 'post' to MF configure this: (set submit as formdata to true)

3. Associate the filedocument to the root - this is your NPE object, configured as Request data (root points to object containing the file). Any other data you wish to sent can be added by creating entities related to the root.

4. rename the assocation to match the field name for the file (e.g. "File")

5. Add the required headers (via JavaAction call addHeaderToNextRequest), place these before the JA call post. For example, an access-token, a bearer-token, application/json etc.

 

Edit: added more screenshots and information about the additional headers

answered
2

If i understand you correctly you want to publish a rest API in Mendix which can be used for multipart file upload?

1 - Publish a Put REST service like described here: https://docs.mendix.com/refguide/published-rest-operation

2 - Note that the Request object should have the image as base 64 encoded value (string), so you can decode it in the microflow of the Put service to an image (make a file object before and decode it using Java ActionBase64DecodeToFile from commons module)

Another possibility is you can receive it directly as binare file with the other data

 

answered
0

Hi

I did like above in my microflow what i hav to do afetr that i want to send multipart form data to my API i used 

rest service module from appstore and called the post java action call from rest service in my microflow

i am not aware of rest service module so anyone help me with the step by step solutiin @Stephan Bruijnis helped me above but can able to get in to this. 

thanks in advance

answered
0

this is my domain model @Stephan Bruijnis

 

answered
0

hi

i have changed the association name as a form field i am getting this error. @Stephan Bruijnis please look at this

answered
0

Hi here is the response am getting from the java action post @Stephan Bruijnis

answered
0

Hi @Stephan Bruijnis. here is the error i am getting with the Dropzone widget

answered