0

I am trying to upload a file using Jersey multipart. Here is my code:

import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;

@Path("/test")
public class Tester {

    @POST
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    @Produces
    public Response test(@FormDataParam("file") InputStream file, @FormDataParam("file") FormDataContentDisposition fileDetail) {
        return Response.status(200).entity(fileDetail.getFileName()).build();
    }
}

Every time I run this code, I get a 400:

the request sent by the client is syntatically incorrect

Edit:

enter image description here

dur
  • 15,689
  • 25
  • 79
  • 125
djdere
  • 321
  • 2
  • 10
  • Is there a stacktrace logs on the server? Can you post that also. The image looks ok. – Paul Samsotha May 04 '17 at 06:49
  • i mean the stack trace is clean. – djdere May 04 '17 at 06:57
  • I don't know then. What you've show looks good. Without any error stacktace, it's hard to debug. Check out the first part of [this post](http://stackoverflow.com/a/33684719/2587435). Add the `DebugMapper` to your application. See if you can get a stack trace that way – Paul Samsotha May 04 '17 at 06:59

1 Answers1

0

Actually removing the Content-Type: multipart/formdata from the header solved the problem. Thank you all for the suggestions

djdere
  • 321
  • 2
  • 10