title: How to unit test a multipart POST request with Spring MVC Test?
body: <p>I am trying to create unit test for REST APi but having big trouble with the uploading excel method.</p>
  
  <p>Here is the method on the controller side</p>
  
  <pre><code>@RestController()
  @RequestMapping(path = "/upload")
  @CrossOrigin(origins = "http://localhost:4200")
  
  public class FileController {
  @Autowired
  FileService fileService;
  
  @PostMapping(value = "/{managerId}/project/{projectId}")
  public List&lt;Task&gt; importExcelFile(@RequestParam("file") MultipartFile files, @PathVariable int managerId,
          @PathVariable int projectId) throws IOException, ParseException {
  
      return fileService.getTasksFromExcel(files, managerId, projectId);
  }
  </code></pre>
  
  <p>Whatever I try I get a lot of errors and evidently I don't really understand what I am supposed to do.</p>
  
  <p>The main error I get is </p>
  
  <pre><code>current request is not a multipart request
  </code></pre>