I've made a resource with Jersey, that can handle file uploads in @FormDataParam
-annotated parameters (the resource is configured to receive query and header parameters too).
Testing with Swagger-UI, as long as I send in a file along with other parameters, everything works fine.
But if I omit the files, and just fill in other parameters, my Java method doesn't receive the request (I verified this with the debugger), which instead ends early with a 400 Bad Request
error.
Class declaration:
@Path("/v1/users")
@Produces("application/json")
@Api("UploadDocumento")
public class UploadDocumentResourcesApiV10 extends CommonResourcesApi {
Method declaration:
@Consumes({MediaType.MULTIPART_FORM_DATA})
@POST @Path("{userRef}/documents")
public Response uploadDocuments(
@HeaderParam("X-Api-Token") String apiToken,
@PathParam("userRef") String contactId,
@QueryParam("desc") String uploadDescription,
@QueryParam("file1Desc") String file1Description,
@FormDataParam("file1") InputStream file1, @FormDataParam("file1") FormDataContentDisposition file1Meta,
@QueryParam("file2Desc") String file2Description,
@FormDataParam("file2") InputStream file2, @FormDataParam("file2") FormDataContentDisposition file2Meta) {
I've checked the browser request headers, in particular the Content-Type
one, and in both cases they're the same.
Even a test with cUrl gives the same error.
What could be wrong?