title: How to upload multiple Multipart files using feign client in Microservice architecture
body: <p>I'm trying to upload multiple multipart file using feign client, but I am not being able to do so. </p>
  
  <p>After few research, 
  <a href="https://stackoverflow.com/questions/31752779/file-upload-using-feign-multipart-form-data">File Upload Using Feign - multipart/form-data</a></p>
  
  <p><a href="https://stackoverflow.com/questions/46522304/file-upload-spring-cloud-feign-client">File upload spring cloud feign client</a></p>
  
  <p><a href="https://stackoverflow.com/questions/49580267/array-multipart-file-upload-using-feign-client">Array Multipart[] file upload using Feign client</a></p>
  
  <p>Client side:</p>
  
  <pre><code>@FeignClient(name = "file-server", configuration = {FileUploadService.MultipartSupportConfig.class})
  @RequestMapping
  public interface FileUploadService {
  
      @RequestMapping(value = "/upload", method = RequestMethod.POST, consumes = MULTIPART_FORM_DATA_VALUE)
      public @ResponseBody
      List&lt;FileUploadResponseDTO&gt; handleFileUpload(@RequestPart(name = "file") MultipartFile[] file);
      @Configuration
      public class MultipartSupportConfig {
  
          @Autowired
          private ObjectFactory&lt;HttpMessageConverters&gt; messageConverters;
  
          @Bean
          @Primary
          @Scope("prototype")
          public Encoder feignEncoder() {
              return new SpringFormEncoder(new SpringEncoder(messageConverters));
          }
      }
  </code></pre>
  
  <p>Module I'm trying to access:</p>
  
  <pre><code>@PostMapping(value = "/upload", consumes = MULTIPART_FORM_DATA_VALUE)
  @ApiOperation(UPLOAD_FILE)
  public List&lt;FileUploadResponseDTO&gt; uploadFiles(@RequestPart(name = "file") MultipartFile[] file){
      System.out.println("****hello ****");
  
      return fileUploadService.uploadFiles(file);
  }
  </code></pre>
  
  <p>The above works fine for a single Multipart file but it shows following error for multiple files:</p>
  
  <p>Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is feign.codec.EncodeException: Could not write request: no suitable HttpMessageConverter found for request type [[Lorg.springframework.web.multipart.MultipartFile;] and content type [multipart/form-data]] with root cause
  feign.codec.EncodeException: Could not write request: no suitable HttpMessageConverter found for request type [[Lorg.springframework.web.multipart.MultipartFile;] and content type [multipart/form-data]</p>