title: Uploading file through REST API with JERSEY
body: <p>Hi have seen a lot of posts about this, but i cannot find my issue.</p>
  
  <p>I keep geeting an error 400</p>
  
  <p>Here is my code</p>
  
  <pre><code>POST
  @Path("/upload")
  @Consumes({MediaType.MULTIPART_FORM_DATA})
  public Response uploadFile(  @FormDataParam("file") InputStream fileInputStream,
                                  @FormDataParam("file") FormDataContentDisposition fileMetaData) throws Exception
  {
      System.out.println(fileMetaData.getFileName());
  
      return Response.ok("File caught successfully !!").build();
  }
  </code></pre>
  
  <p>Here are my Jersey dependencies</p>
  
  <pre><code>       &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.core&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-server&lt;/artifactId&gt;
              &lt;version&gt;2.25&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.media&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-media-multipart&lt;/artifactId&gt;
              &lt;version&gt;2.25&lt;/version&gt;
          &lt;/dependency&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.glassfish.jersey.containers&lt;/groupId&gt;
              &lt;artifactId&gt;jersey-container-servlet-core&lt;/artifactId&gt;
              &lt;version&gt;2.18&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>And I've added this to the AppConfiguration</p>
  
  <pre><code>@Override
  public Set&lt;Class&lt;?&gt;&gt; getClasses() {
      Set&lt;Class&lt;?&gt;&gt; resources = new java.util.HashSet&lt;&gt;();
      addRestResourceClasses(resources);
      resources.add(MultiPartFeature.class);
      return resources;
  }
  </code></pre>
  
  <p>In all fairness, it could be my actual HTTP request, so here is my POSTman</p>
  
  <p><a href="https://i.stack.imgur.com/vkGuq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vkGuq.png" alt="Postman body"></a><a href="https://i.stack.imgur.com/3v6l6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3v6l6.png" alt="postman header"></a></p>