title: Multipart Request using Retrofit 1.8.0 not working
body: <p>I have like 4 days, trying to make a Multipart Request using Retrofit 1.8.0 in android with any success.  My interface looks something like this</p>
  
  <pre><code>@Multipart
  @POST("/posts/add.json") 
  void addComment(
    @Part("id") String id,
    @Part("post[body]") String body,
    @Part("post[attachment]") TypedFile attachment,
    Callback&lt;Map&lt;String, String&gt;&gt; callback );
  </code></pre>
  
  <p>But, in the server side, I receive the following</p>
  
  <pre><code>Parameters: {"id"=&gt;# &lt;File:/var/folders/z0/0ggjvvfj4t1fdsvbxf3lc9pw0000gn/T/RackMultipart9853-0&gt;, "post"=&gt;{"body"=&gt;#&lt;File:/var/folders/z0/0ggjvvfj4t1fdsvbxf3lc9pw0000gn/T/RackMultipart9853-1&gt;, "attachment"=&gt;#&lt;File:/var/folders/z0/0ggjvvfj4t1fdsvbxf3lc9pw0000gn/T/RackMultipart9853-2&gt;}, "controller"=&gt;"posts", "action"=&gt;"add", "format"=&gt;"json"}
  </code></pre>
  
  <p>As you can see, the file part is sending it in every part but and I'm missing the parameters' value  of id and post[body]</p>
  
  <p>Here it's what Retrofit is trying to send</p>
  
  <pre><code> 02-06 15:01:16.213    32545-822/com.myapp D/Retrofit﹕ --fe41634b-6826-4ee4-95cb-65efb0ca66c2
  Content-Disposition: form-data; name="id"
  Content-Type: text/plain; charset=UTF-8
  Content-Length: 3
  Content-Transfer-Encoding: binary
  189
  --fe41634b-6826-4ee4-95cb-65efb0ca66c2
  Content-Disposition: form-data; name="post[body]"
  Content-Type: text/plain; charset=UTF-8
  Content-Length: 4
  Content-Transfer-Encoding: binary
  test
  --fe41634b-6826-4ee4-95cb-65efb0ca66c2
  Content-Disposition: form-data; name="post[attachment]"; filename="IMG_20140203_144358.jpg"
  Content-Type: image/jpg
  Content-Length: 1615460
  Content-Transfer-Encoding: binary
  ����/�Exif����MM��*���������
  </code></pre>
  
  <p>Here it is what the HttpMime library is sending in the Multipart, the difference is the "Content-Transfer-Encoding" header against Retrofit</p>
  
  <pre><code>Content-Disposition: form-data; name="id"
  Content-Type: text/plain; charset=US-ASCII
  Content-Transfer-Encoding: 8bit
  
  Content-Disposition: form-data; name=“post[body]"
  Content-Type: text/plain; charset=US-ASCII
  Content-Transfer-Encoding: 8bit
  
  Content-Disposition: form-data; name=“post[attachment]"; filename="images.jpg"
  Content-Type: image/jpg
  Content-Transfer-Encoding: binary
  </code></pre>
  
  <p>Any clue? Thanks in advance</p>
  
  <p><strong>-------------------------------SOLUTION----------------------------------</strong></p>
  
  <p>At the end, I resolved this way, actually my answer is pretty close to @lazypig, it was a good guideline</p>
  
  <p>The only thing that I changed was his class "ByteArrayTypedOutput"</p>
  
  <p>I created a class called "MultipartTypedOutputCustom" <a href="http://pastie.org/10549360" rel="nofollow">http://pastie.org/10549360</a></p>
  
  <p>And this is, how it looks my interface now</p>
  
  <p>"PostsRetrofitAPI.java" class</p>
  
  <pre><code>@POST("/posts/add.json")
      void addComment(@Body MultipartTypedOutputCustom parts,
                      Callback&lt;Map&lt;String, String&gt;&gt; callback);
  </code></pre>
  
  <p>"PostsService.java"class</p>
  
  <pre><code>//Properties
  private PostsRetrofitAPI mApi;
  ...
  
      @Override
          public void addComment(ServiceResponseHandler&lt;Map&lt;String, String&gt;&gt; handler, String id, String body, TypedFile attachment) {
             MultipartTypedOutputCustom parts = new MultipartTypedOutputCustom();
             parts.addPart("id", new TypedString(id));
             parts.addPart("post[body]", new TypedString(body));
             parts.addPart("post[attachment]", attachment);
      objectRetrofitCallback= new ObjectRetrofitCallback(handler, ServerError.class, ClientError.class);
              mApi.addComment(parts, objectRetrofitCallback);
          }
  </code></pre>