title: Use REST client to call multipart/form-data Rest web service
body: <p>I have a RESTeasy-based REST web service (see below). I'm trying to use the google REST client to execute a request to test my service, but I'm unsure as to how the request should be setup.</p>
  
  <p>I'm not sure how to send the <code>byte[]</code> as a param (<code>filedata</code>).<br>
  Any ideas on how to test this? </p>
  
  <p>I get the following exception:</p>
  
  <blockquote>
    <p>java.io.IOException: Unable to get boundary for multipart</p>
  </blockquote>
  
  <p>with</p>
  
  <pre><code>request:
  -content-type=multipart/form-data
  -form params:
  test=testvalue
  </code></pre>
  
  <p>Rest method:</p>
  
  <pre><code>@POST
  @Path("/upload")
  @Consumes("multipart/form-data")
  public Response create(@MultipartForm FileUploadForm form) {
     System.out.println("form=" + form.getTest());
     return null;
  }
  </code></pre>
  
  <p>FileUploadForm Pojo:</p>
  
  <pre><code>import javax.ws.rs.FormParam;
  import org.jboss.resteasy.annotations.providers.multipart.PartType;
  
  public class FileUploadForm {
      private byte[] filedata;
      private String test;
  
      public FileUploadForm() {}
  
      public byte[] getFileData() {
          return filedata;
      }
  
      @FormParam("filedata")
      @PartType("application/octet-stream")
      public void setFileData(final byte[] filedata) {
          this.filedata = filedata;
      }
  
      public String getTest() {
          return test;
      }
  
      @FormParam("test")
      @PartType("application/json")
      public void setTest(String test) {
          this.test = test;
      }   
  }
  </code></pre>