Unsupported Media Type (415) Error while implementing File upload using
Jersey in Mule
I am trying to implement File Upload using Jersey module in Mule.
My mule flow looks like this:
<flow name="rest-service">
<inbound-endpoint address="http://localhost:9999/testupload"/>
<jersey:resources>
<component class="com.example.test.UploadFileResource"/>
</jersey:resources>
</flow>
If I don't put @Consumes annotation in the resource method in
UploadFileResource like below, the method gets called when an HTTP Post
request is made using multipart/form-data Content-type and I get HTTP 2xx
status code:
@Path("/uploadfile")
public class UploadFileResource {
@POST
public Response uploadFile2(...) {
logger.info("Multipart Upload");
...
}
}
But when I put @Consumes annotation with MULTIPART_FORM_DATA Media Type
like below, the method does not get called and I get HTTP 415 Unsupported
Media type, even when the HTTP Post request is made using
multipart/form-data Content-type:
@Path("/uploadfile")
public class UploadFileResource {
@POST
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile2(...) {
logger.info("Multipart Upload");
...
}
}
Any idea why 415 status comes even when @Consumes Media type matches the
HTTP Post Content-type header?
No comments:
Post a Comment