title: BAD Request 400 consume multipart/form-data jersey clientresponse java
body: <p>I need consume a service, the file is a excel.
  But  when I execute the consume the response is this "returned a response status of 400 Bad Request"</p>
  
  <pre><code>String authString = name + ":" + password;
  Client restClient = Client.create();
  String authStringEnc = Base64.getEncoder().encodeToString(authString.getBytes());
  // the file to upload, represented as FileDataBodyPart
  FileDataBodyPart fileDataBodyPart = new FileDataBodyPart("file", new File(file),
          MediaType.APPLICATION_OCTET_STREAM_TYPE);
  // fileDataBodyPart.setContentDisposition(FormDataContentDisposition.name("file").fileName(file).build());
  
  FormDataMultiPart multiPart = new FormDataMultiPart();
  multiPart.field("spId", idServicio, MediaType.MULTIPART_FORM_DATA_TYPE).bodyPart(fileDataBodyPart);
  multiPart.setMediaType(MediaType.MULTIPART_FORM_DATA_TYPE);
  
  WebResource webResource = restClient.resource(url);
  ClientResponse resp = webResource.header("Authorization", "Basic " + authStringEnc)
          .header("Content-Type", "multipart/form-data").post(ClientResponse.class, multiPart);
  
  String output = resp.getEntity(String.class);
  System.out.print(output);
  return resp;
  </code></pre>