title: How to create a repeatable POST request that contains multipart-form-data?
body: <p>I am trying to create a <code>POST</code> request that contains <code>multipart-form-data</code> that requires <code>NT Credentials</code>. The authentication request causes the <code>POST</code> to be resent and I get a unrepeatable entity exception.</p>
  
  <p>I tried wrapping the <code>MultipartContent</code> entity that is produced with a <code>BufferedHttpEntity</code> but it throws <code>NullPointerExceptions</code>?</p>
  
  <pre><code>final GenericUrl sau = new GenericUrl(baseURI.resolve("Record"));
  final MultipartContent c = new MultipartContent().setMediaType(MULTIPART_FORM_DATA).setBoundary("__END_OF_PART__");
  final MultipartContent.Part p0 = new MultipartContent.Part(new HttpHeaders().set("Content-Disposition", format("form-data; name=\"%s\"", "RecordRecordType")), ByteArrayContent.fromString(null, "C_APP_BOX"));
  final MultipartContent.Part p1 = new MultipartContent.Part(new HttpHeaders().set("Content-Disposition", format("form-data; name=\"%s\"", "RecordTitle")), ByteArrayContent.fromString(null, "JAVA_TEST"));
  c.addPart(p0);
  c.addPart(p1);
  </code></pre>
  
  <p>The documentation for <code>ByteArrayContent</code> says </p>
  
  <blockquote>
    <blockquote>
      <p>Concrete implementation of AbstractInputStreamContent that generates repeatable input streams based on the contents of byte array.</p>
    </blockquote>
  </blockquote>
  
  <p>Making all the <em>parts</em> repeatable does not solve the problem. Because this code
  <code>System.out.println("c.retrySupported() = " + c.retrySupported());</code> outputs <code>c.retrySupported() = true</code>.</p>
  
  <p>I found the following documentation:</p>
  
  <blockquote>
    <p>1.1.4.1. Repeatable entities An entity can be repeatable, meaning its content can be read more than once. This is only possible with self
    contained entities (like ByteArrayEntity or StringEntity)</p>
  </blockquote>
  
  <p>I have now converted my <code>MultipartContent</code> to a <code>ByteArrayContent</code> with a <code>multi/part-form</code> media type by extracting the string contents and still get the same error!</p>
  
  <p>But I still get the following exception when I try and call <code>request.execute()</code>.</p>
  
  <pre><code>Caused by: org.apache.http.client.NonRepeatableRequestException: Cannot retry request with a non-repeatable request entity.
  </code></pre>
  
  <h3>So how do I go about convincing the <code>ApacheHttpTransport</code> to create a repeatable Entity?</h3>