title: How do you POST a FormData object in Angular 2?
body: <p>I need to upload a file and send some json along with it, I have this function:</p>
  
  <pre><code>POST_formData(url, data) {
          var headers = new Headers(), authtoken = localStorage.getItem('authtoken');
  
          if (authtoken) {
              headers.append("Authorization", 'Token ' + authtoken)
          }
  
          headers.append("Accept", 'application/json');
          headers.delete("Content-Type");
  
          var requestoptions = new RequestOptions({
              method: RequestMethod.Post,
              url: this.apiURL + url,
              headers: headers,
              body: data
          })
  
          return this.http.request(new Request(requestoptions))
  
          .map((res: Response) =&gt; {
              if (res) {
                  return { status: res.status, json: res.json() }
              }
          })
      }
  </code></pre>
  
  <p>My issue is, if I set the <code>content-type</code> to "<code>multipart/form-data</code>" my server complains about the boundaries, if I remove the <code>content-type</code> header completely, my server complains that it "<code>text/plain</code>" a supported media type.</p>
  
  <p>So, how do you send FormData with angular2?</p>