title: Spring: JSON data and file in the same request
body: <p>I know how to create endpoints that are handling files using <code>MediaType.MULTIPART_FORM_DATA</code> and <code>@FormDataParam("file") FormDataBodyPart bodyPart</code>, but I was wondering if I can also have JSON data along that request? Something like:</p>
  
  <pre><code>    @POST
      @Path("somepath")
      @Consumes(MediaType.MULTIPART_FORM_DATA)
      public Response uploadFileAndJSON(@RequestBody SomeModel someModel,
                                        @FormDataParam("file") FormDataBodyPart bodyPart) { 
           return null;
      }
  </code></pre>
  
  <p>At the moment if I add some JSON data on the "raw" tab on the following Postman request I'm getting <code>HTTP 415 Unsupported Media Type</code> probably because I specified that I consume <code>MULTIPART_FORM_DATA</code> but I'm also using <code>@RequestBody</code> which is looking for JSON content which is <code>APPLICATION_JSON</code>. So how can I have JSON data and a file handled in the same request? I know that it's possible to do that in two requests, I just want to do it in one if possible?</p>
  
  <p><a href="https://i.stack.imgur.com/f4Zfk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/f4Zfk.png" alt="enter image description here"></a></p>