Unable to send FileDocument in REST form-data and missing Binary return type in Java Action (Java not detected)
0
Question: I am trying to call a FastAPI endpoint from Mendix using a POST request with multipart/form-data, where the key "file" must contain an uploaded Excel file. I am facing multiple issues: The REST Call form-data configuration does not allow selecting a FileDocument in the "Value" field. The dropdown only shows simple types and does not provide a way to attach the uploaded file. When I create a Java Action in my module, the Binary return type is not available. Only String, Boolean, Integer, and Object are shown. Because of this, I cannot return byte[] or binary content. In Studio Pro, there is no "Java" tab under Preferences → Advanced. Also, when creating a Java Action, no .java file is generated inside the javasource folder. It seems like Java support is not active in my project, even though JDK 17 is installed on my system. Because Mendix cannot convert a FileDocument into binary, the REST POST request ends up sending an empty file. My FastAPI endpoint expects actual file bytes, so the backend receives no file and the process fails. I need help with the following: How can I enable full Java support in Mendix Studio Pro so that Binary return type becomes available, the Java tab appears, and Java source files are generated normally? How can I correctly convert a FileDocument into binary (byte[]) so that it can be sent through a REST Call as multipart/form-data? Is there a known issue with Java detection or configuration in Mendix 11.3, and what is the correct way to link JDK 17 so that Studio Pro recognizes it? Environment:Mendix Studio Pro version: 11.3JDK version: 17Windows OSUsing CommunityCommonsCalling external FastAPI REST endpoint
asked
Sania Mulla
2 answers
1
You should be able to just use a FileDocument parameter (or specialisation thereof):
As for your Java troubles, use Java 21 and also, use a FileDocument parameter. The Contents attribute will contain the binary.
answered
Martin Koelewijn
0
Hello Sania,
you can extract binary from FileDocument type object. Change Request option in Rest Call to "Binary for the entire request"->Select your object and use Contents attribute of it. Then you will have the whole binary of the object extracted and send through the Rest Call.