title: Angular 2 - Post File to Web API
body: <p>I am attempting to pass a file to Web API from an Angular 2 app, and the actual file data does not get sent. </p>
  
  <p>Here is my angular 2 service code: </p>
  
  <pre><code>        var headers = new Headers();
          headers.append('Content-Type', 'multipart/form-data');
  
          var formData = new FormData();
          formData.append("file", file);
  
          return this.http.post('http://myapiurl.com/files/upload', formData, { headers: headers }).map(res =&gt; res.json());
  </code></pre>
  
  <p>In the angular 2 docs, the POST method signature is as follows: </p>
  
  <pre><code>post(url: string, body: string, options?: RequestOptionsArgs) : Observable&lt;Response&gt;
  </code></pre>
  
  <p>There is no option to pass Form Data, or other object. Just a string in the bodys request.   The current work around is to use javascript and regular xhr requests.  There are obvious downsides to this like not being able to use observables, etc. </p>
  
  <p>Any help on this would be greatly appreciated. </p>