title: How to send a multipart request with RestAssured?
body: <p>I have <code>@Controller</code> with method with signature like this:</p>
  
  <pre><code>@PostMapping
  @ResponseBody
  public ResponseEntity&lt;Result&gt; uploadFileAndReturnJson(@RequestParam("file") MultipartFile file) {}
  </code></pre>
  
  <p>I want to construct multipart request without physically creating any file. I tried doing it like this:</p>
  
  <pre><code>private MultiPartSpecification getMultiPart() {
      return new MultiPartSpecBuilder("111,222")
              .mimeType(MimeTypeUtils.MULTIPART_FORM_DATA.toString())
              .controlName("file")
              .fileName("file")
              .build();
  }
  
  Response response = RestAssured.given(this.spec)
              .auth().basic("admin", "admin")
              .multiPart(getMultiPart())
              .when().post(URL);
  </code></pre>
  
  <p>Unfortunately I received response:</p>
  
  <blockquote>
    <p>Required request part 'file' is not present</p>
  </blockquote>
  
  <p>I tried looking at RestAssured unit tests and it seems I'm doing it correctly. If I try to pass byte[] or InputStream instead of String, an exception is thrown:</p>
  
  <blockquote>
    <p>Cannot retry request with a non-repeatable request entity.</p>
  </blockquote>
  
  <p>Thanks for help.</p>