I have a javax.ws.rs.*
REST endpoint which I am trying to upload a file with. So the endpoint receives a document and a list of parameters.
It gets the following error:
HTTP Status 415 - Cannot consume content type
Question
Any ideas what I am doing wrong and how do I change my code to consume the document and paramaters?
Here is my code:
@POST
@Path("override")
@ApiOperation(value="Receives the override info for a trip ('overrideConclusion':'Approved'/'Reject').")
@ApiResponses({
@ApiResponse(code=200, message="Success"),
@ApiResponse(code=404, message="Not Found")
})
@Consumes(MediaType.MULTIPART_FORM_DATA)
//@Consumes({"text/*","application/*"})
@Produces(MediaType.APPLICATION_JSON)
public Response override(@HeaderParam("Authorization") String token, @Context HttpServletRequest request,
@ApiParam(required = true) byte[] data, @ApiParam(required = true) @QueryParam("tripId") Long tripId, @QueryParam("overrideReason") String overrideReason,
@QueryParam("overrideConclusion") String overrideConclusion, @QueryParam("authorizedApproverPersonId") Long authorizedApproverPersonId, @QueryParam("fileName") String fileName) {
I use Postman to test it:
The file to upload
The parameters
Full error:
<body>
<h1>HTTP Status 415 - Cannot consume content type</h1>
<HR size="1" noshade="noshade">
<p><b>type</b> Status report</p>
<p><b>message</b> <u>Cannot consume content type</u></p>
<p><b>description</b> <u>The server refused this request because the request entity is in a format not supported by
the requested resource for the requested method (Cannot consume content type).</u></p>
<HR size="1" noshade="noshade">
<h3>JBoss Web/7.0.1.Final</h3>
</body>