REST POST to upload file - multipart/form-data

1
I am trying to upload a file using the Mendix REST call with the Form-data option. My code works in swagger and Postman but it does not work in Mendix. In the Request tab, using Form-data I think the setup is not correct as I get a “Error calling REST service; 400: Bad Request” message. The difference between Mendix and Postman is that Postman uses a link to the file location “cadfile=@...” whereas Mendix is sending a binary file. The $NewImportGeometry_File_3 is a File document.  I am not sure what the right setup is in Mendix. I would appreciate any guidance. Thanks.   form-data documentation does not help – https://docs.mendix.com/refguide/call-rest-action#4-3-form-data This helped with the entity setup – https://docs.mendix.com/howto/data-models/working-with-images-and-files  
asked
2 answers
1

In Mendix 8.9.0, an issue was fixed in posting multipart/form-data. Maybe you’re experiencing that issue?

answered
0

The form-data from Mendix can be used if you put correct headers. 

HTTP Headers section in REST call should include all these ( No content-type header as Mendix puts it by default and even if you try to , Mendix gives you an error message) 

  • Accept : */*
  • Accept-Encoding : gzip, deflate, br
  • Connection : keep-alive

 

Request section in REST call should include 

  • Key : File
  • Value : the filedocument object of your application

 

This was tested with Mendix 8.17.0

answered