title: Jersey REST Client : Posting MultiPart data
body: <p>I am trying to write a Jersey client app which can post multi part form data to a Restful Jersey service. I need to post a CSV file with the data and a JSON with meta-data. I am using Jersey client 1.18.3. Here is my code (some names have been changed for company confidentiality )...</p>
  
  <pre><code>Client client = Client.create();
  WebResource webResource = client.resource("http://localhost:8080/mariam/service/playWithDad");
  
  
      FileDataBodyPart filePart = new FileDataBodyPart("file", 
              new File("C:/Users/Admin/Desktop/input/games.csv"));
  
      String playWithDadMetaJson
      = "{\n"
      + "    \"sandboxIndicator\": true,\n"
      + "    \"skipBadLines\": false,\n"
      + "    \"fileSeparator\": \"COMMA\",\n"
      + "    \"blockSize\": false,\n"
      + "    \"gameUUID\": \"43a004c9-2130-4e75-8fd4-e5fccae31840\",\n"
      + "    \"useFriends\": \"false\"\n"
      + "}\n"
      + "";
  
      MultiPart multipartEntity = new FormDataMultiPart()
      .field("meta", playWithDadMetaJson, MediaType.APPLICATION_JSON_TYPE)
      .bodyPart(filePart);
  
      ClientResponse response = webResource.type(MediaType.MULTIPART_FORM_DATA_TYPE).post(multipartEntity);
  </code></pre>
  
  <p>Right now I am getting a compile error at the last line saying it cannot convert from void to ClientResponse. </p>
  
  <p>I got some guidance on the RestFul service itself previously from this post..</p>
  
  <p><a href="https://stackoverflow.com/questions/27643558/java-rest-jersey-posting-multiple-types-of-data-file-and-json">Java Rest Jersey : Posting multiple types of data (File and JSON)</a></p>