title: Transfer .xls files through POST request in Java REST Api
body: <p>I'm new to Spring and I have some troubles in receiving a .xls file from the front-end through a POST request. Bassicaly when I accesss the link "Project/File" I receive error code 400(bad request) but the parameters names are the same both in front-end and back-end.  </p>
  
  <p>Here is my code so far:  </p>
  
  <pre><code>@Controller
  public class RestController {
  
      @Autowired
      private FileService fileService;
  
      @Consumes("application/vnd.ms-excel")
      @RequestMapping(value = "Project/File",
              method = {RequestMethod.POST, RequestMethod.GET},
              params = {"inputXLS"})
      public @ResponseBody void getCitiriContoriMecanici(
              @RequestParam(value = "inputXLS" , required = true) InputStream inputStream) throws IOException{
  
          //transform the InputStream to an array of bytes;
          byte[] bytes = IOUtils.toByteArray(inputStream);
  
          //create a new .xls file
          File file = new File("TEST.xls");  
          FileOutputStream fileOutputStream = new FileOutputStream(file);
          //write a the bytes to a new .xls file
          fileOutputStream.write(bytes);
          fileOutputStream.flush();
          fileOutputStream.close();
  
          fileService.getFileFromFrontEnd();//this method is used to parse the .xls file
      }
  
  }
  </code></pre>
  
  <p>Can anyone give me an idea how to solve this problem?</p>