title: Multipart/form-data construction with android
body: <p>I am trying to make an <code>HttpPost</code> with <code>multiPart/form-data</code> via my android app.  I have a postman test that is working with my api and the preview of that request in postman, looks like this:</p>
  
  <pre><code>POST /api/0.1/content/upload HTTP/1.1
  Host: 54.221.194.167
  X-AUTHORIZATION: 166e649911ff424eb14446cf398bd7d6
  Cache-Control: no-cache
  Postman-Token: 2412eba9-f72d-6f3b-b124-6070b5b26644
  
  ----WebKitFormBoundaryE19zNvXGzXaLvS5C
  Content-Disposition: form-data; name="file01"
  
  {"mime_type":"image/jpeg","title":"IMG_20140131_111622"}
  ----WebKitFormBoundaryE19zNvXGzXaLvS5C
  Content-Disposition: form-data; name="file01"; filename="addedaslib.jpg"
  Content-Type: image/jpeg
  
  
  ----WebKitFormBoundaryE19zNvXGzXaLvS5C
  </code></pre>
  
  <p>I am trying to replicate that using the multipart/form-data with my android HttpPost but it doesn't seem to be working.   Is there a way to "preview" my request and see how it is actually posting to the api?  what am i doing wrong?  my code:</p>
  
  <pre><code>public HttpResponse invokeXAUTHPOSTService(String url, String token, File file) {
  
  
          client = new DefaultHttpClient();
          HttpPost request = new HttpPost(url);
          HttpResponse response = null; 
          MultipartEntity mpe = new MultipartEntity();
      try {
  
  
          Log.v("API", "URL:"+url);
          request.setHeader("Content-Type", "multipart/form-data");
          request.addHeader("X-AUTHORIZATION",token);
          request.addHeader("Cache-Control", "no-cache");
  
          DRPContentForUpload content = new DRPContentForUpload(file);
          String jsonObject = DRPJSONConverter.toJson(content);
  
          FormBodyPart part1= new FormBodyPart("file01", new StringBody(jsonObject));
          FormBodyPart part2= new FormBodyPart("file01", new FileBody(file)); 
          mpe.addPart(part1);
          mpe.addPart(part2);
  
          //
  
          request.setEntity(mpe);
          Log.v("RAW REQUEST", "request looks like:"+mpe.toString());
          response = client.execute(request);
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>I was able to talk to my API team, and they said my post actually looks like this:</p>
  
  <pre><code>--0ieMJK6PPwcrM_K3KQvl6eNDGqooZPzJcvHOm0
  Content-Disposition: form-data; name="file01"
  Content-Type: text/plain; charset=US-ASCII
  Content-Transfer-Encoding: 8bit
  
  {"mime_type":"image/jpeg","title":"IMG_20140131_111622"}
  --0ieMJK6PPwcrM_K3KQvl6eNDGqooZPzJcvHOm0
  Content-Disposition: form-data; name="file01"; filename="IMG_20140131_111622.jpg"
  Content-Type: application/octet-stream
  Content-Transfer-Encoding: binary
  </code></pre>
  
  <p>That said its still not working and spitting back an error that i am missing params</p>
  
  <p>here is a screen shot of the libraries included in my project:</p>
  
  <p><img src="https://i.stack.imgur.com/WslY3.png" alt="enter image description here"></p>