I'm trying to send a document to a remote API with RestEasy on Quarkus.
The API I'm calling requires me to send a multipart/form-data body with 3 files. Problem is, the API cares about the order in which they are specified and will return an error if they are in the wrong order.
The problem seems similar to this question, but the problem there concerns a server returning data, while my problem concerns a client sending data. I posted a comment anyway and will delete this question if something resolutive comes up there.
The parameters are called PARAMETERS, INDEX and DATA and need to be specified in this exact order and intentionally uppercased. I'm using a MultipartFormDataOutput to store the files to send and as the other question suggests, it might be a problem with the keys being ordered alphabetically.
This is the service interface I'm using:
@ApplicationScoped
@RegisterRestClient(configKey = "api-url")
public interface DocuService {
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_OCTET_STREAM)
@Path("/send_document")
String sendDocument(
@MultipartForm MultipartFormDataOutput data
);
}
While this is how I add the files to the payload and send it:
MultipartFormDataOutput mpFormData = new MultipartFormDataOutput();
mpFormData.addFormData("PARAMETERS", requestData.getParamFile(), new MediaType("application", "xml"), "parametersFile.xml");
mpFormData.addFormData("INDEX", requestData.getIndexFile(), new MediaType("application", "xml"), "indexFile.xml");
mpFormData.addFormData("DATA", requestData.getDataFile(), new MediaType("application", "json"), "dataFile.json");
docuService.sendDocument(
mpFormData
);
I can't find a way to specify the key order, or maybe a similar object that will allow me to do so. Maybe someone can help me shed some light on this.
Thanks in advance and have a nice day!