title: Current request is not a multipart request-When i send form data and an object in angular to spring boot
body: <p>I'm sending a custom Object and formData to Spring boot from angular but an error is thrown -"Current request is not a multipart request".</p>
  
  <p>when i do this everything works fine</p>
  
  <p>Angular</p>
  
  <pre><code>private base_url = "http://localhost:8082";
  
  
    addProduct(product:Product,file:File) :Observable&lt;any&gt;
    {
        const headers = new HttpHeaders({
        Authorization: 'Bearer ' + sessionStorage.getItem("authToken")})
  
        let formData = new FormData();
        formData.append("file",file);
  
      return this.httpClient.post&lt;any&gt;(this.base_url+"/api/addProduct",formData,{headers});
   or 
  return this.httpClient.post&lt;any&gt;(this.base_url+"/api/addProduct",product,{headers});
  </code></pre>
  
  <p>spring(corresponding to the above)</p>
  
  <pre><code>    @PostMapping("/addProduct")
      public void addProduct(@RequestParam("file") MultipartFile file) throws IOException
      {
  
      }
  or
  @PostMapping("/addProduct")
      public void addProduct(@RequestBody Product product)
      {
  
      }
  </code></pre>
  
  <p>My current implementation is the code below but it doesn't work.
  I get an error -Current request is not a multipart request.
  How can i send both Product and formData to spring boot app.I need help.
  angular</p>
  
  <pre><code>private base_url = "http://localhost:8082";
  
  
       //add product
        addProduct(product:Product,file:File) :Observable&lt;any&gt;
        {
            const headers = new HttpHeaders({
            Authorization: 'Bearer ' + sessionStorage.getItem("authToken")})
  
            let formData = new FormData();
            formData.append("file",file);
  
          return this.httpClient.post&lt;any&gt;(this.base_url+"/api/addProduct",{product,formData},{headers});
  
        }
  </code></pre>
  
  <p>spring</p>
  
  <pre><code> //add product
  @PostMapping("/addProduct")
  public void addProduct(@RequestBody Product product,@RequestParam("file") MultipartFile file) throws IOException
  {
  }
  </code></pre>