I have created a rest API to accept MULTIPART_FORM_DATA
as below. But once I hit the service using Postman, I am getting HTTP Status 415 – Unsupported Media Type exception
@POST
@Path("/fileupload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces(MediaType.APPLICATION_JSON)
public String uploadfile(@RequestParam(value = "file") MultipartFile file) {
System.out.println(file.getName());
return "Success String";
}
What is wrong here? To consume MediaType.MULTIPART_FORM_DATA
, do I need to make any modifications?
In Postman I have attached a text file in the BODY and hit the endpoint. The content type is set as "multipart/form-data"