I'm trying to implement a RESTful API with Swagger 2.0 tu upload a CSV file with Java backend; This is the swagger definition for the API:
/mobileCommunications/importCallDetails:
post:
operationId: importCallDetails
summary: Uploads a file that contains the call details for a specific period.
tags:
- MobileCommunications
consumes:
- multipart/form-data
parameters:
- in: formData
name: upfile
type: file
responses:
'200':
description: file uploaded successfully
And, that's the code generated by Swagger:
@POST
@Path("/importCallDetails")
@Consumes({ "multipart/form-data" })
@Produces({ "application/json; charset=utf-8" })
@io.swagger.annotations.ApiOperation(value = "Uploads a file that contains the call details for a specific period.", notes = "", response = Void.class, tags={ "MobileCommunications", })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "file uploaded successfully", response = Void.class) })
public Response importCallDetails(MultipartFormDataInput input,@Context SecurityContext securityContext,@Context Request request,@Context HttpServletRequest httpServletRequest) throws ApplicationException;
And this is my controller code (which is not executed at all anyway that's why it's empty):
@Override
public Response importCallDetails(MultipartFormDataInput input, SecurityContext securityContext, Request request,
HttpServletRequest httpServletRequest) throws ApplicationException {
return null;
}
And this is the maven dependencies related to this:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
<version>4.5.4.Final</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.12</version>
</dependency>
But, i still get this error in the backend whenever i try to upload the file:
Caused by: org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyReader not found for media type=multipart/form-data; boundary=----WebKitFormBoundaryvmfNnOPmhX557ZUx, type=interface org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput, genericType=interface org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput.
I'm stuck with this problem for about a week now and i don't make any progress toward the solution, so any help will make a difference here :)
Thank you