title: how to set content type to multipart/form-data in angular 7
body: <p>I know this type of question has asked several times in here and some forums.</p>
  
  <p>What i'm trying to do is upload a file to my server. Down below is my first attempt to set headers to <code>multipart/form-data</code>. Below is my service for the file upload.</p>
  
  <pre><code>uploadNewFile (formData): Observable&lt;any&gt; {
      const headers = new HttpHeaders();
      headers.set('Content-Type', undefined);
      return this.http.post(environment.baseURL+'api/v1/company/someFileUpload' , formData, {headers: headers})
        .pipe(
          catchError(this.formatErrors)
        );
    }
  </code></pre>
  
  <p>But when i do this, i'm getting this error.</p>
  
  <blockquote>
    <p>Error: Multipart: Boundary not found</p>
  </blockquote>
  
  <p>But then after seeing this question(<a href="https://stackoverflow.com/questions/35722093/send-multipart-form-data-files-with-angular-using-http">Send multipart/form-data files with angular using $http</a>) i changed my header to this.</p>
  
  <pre><code>const headers = new HttpHeaders();
  headers.set('Content-Type', undefined)
  </code></pre>
  
  <p>But when I changed it like that, I am getting this error.</p>
  
  <p><a href="https://i.stack.imgur.com/hLK56.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hLK56.png" alt="enter image description here"></a></p>
  
  <p>But when i check an aswer for that error it says that i need to add a handler in here (<a href="https://stackoverflow.com/questions/55019512/uncaught-typeerror-cannot-read-property-ngoriginalerror-of-undefined-at-getor">Uncaught TypeError: Cannot read property &#39;ngOriginalError&#39; of undefined at getOriginalError - when httpClient returned string</a>)</p>
  
  <p>But i have a handler for my service. Service is pasted in below.</p>
  
  <pre><code>uploadNewFile (formData): Observable&lt;any&gt; {
      const headers = new HttpHeaders();
      headers.set('Content-Type', undefined);
      return this.http.post(environment.baseURL+'someFileUpload' , formData, {headers: headers})
        .pipe(
          catchError(this.formatErrors)
        );
    }
  </code></pre>
  
  <p>How can i solve this?</p>