title: Angular2 problems with sending post request
body: <p>I have a simple code for send post request to my local server.
  Like this:</p>
  
  <pre><code>  login(event, username, password) {
      event.preventDefault();
      let body = "grant_type=password&amp;username=" + username + "&amp;password=" + password;
      this.http
        .post(`${appSettings.API_ENDPOINT_DEV}Login`, body, {headers: contentHeaders})
        .subscribe(
          response =&gt; {
            this.accessToken = response.json().access_token;
            console.log(this.accessToken);
            localStorage.setItem('access_token', this.accessToken);
          },
          error =&gt; {
            alert(error.text());
            console.log(error.text());
          }
        );
    }
  </code></pre>
  
  <p>But I catch next exception in the google chrome dev console.</p>
  
  <blockquote>
    <p>XMLHttpRequest cannot load <a href="http://localhost:1216/api/Login" rel="nofollow">http://localhost:1216/api/Login</a>. Response
    for preflight has invalid HTTP status code 400</p>
  </blockquote>
  
  <p>Help me please fix this problem because with Angular 1.x all work well.
  Log from google chrome console:</p>
  
  <pre><code>   Request URL:http://localhost:1216/api/Login
      Request Method:OPTIONS
      Status Code:400 Bad Request
      Remote Address:[::1]:1216
      Access-Control-Allow-Origin:*
      Cache-Control:no-cache
      Content-Length:34
      Content-Type:application/json;charset=UTF-8
      Date:Thu, 04 Aug 2016 11:43:21 GMT
      Expires:-1
      Pragma:no-cache
      Server:Microsoft-IIS/10.0
      X-Powered-By:ASP.NET
      X-SourceFiles:=?UTF-8?B?RDpcU291cmNlc1xHcmFwcHNcVUtfQnJhbmRQcm90ZWN0aW9uXFdlYkFQSVxhcGlcTG9naW4=?=
  </code></pre>
  
  <p><strong>UPD:</strong></p>
  
  <pre><code>export const contentHeaders = new Headers();
  contentHeaders.append('Content-Type', 'application/x-www-form-urlencoded');
  contentHeaders.append('Access-Control-Allow-Origin', '*; *');
  contentHeaders.append('Access-Control-Allow-Methods', 'POST');
  </code></pre>
  
  <p><strong>UPD2</strong>
  Log from advanced REST client</p>
  
  <pre><code>Cache-Control: no-cache
  Pragma: no-cache
  Content-Type: application/json;charset=UTF-8
  Expires: -1
  Server: Microsoft-IIS/10.0
  Access-Control-Allow-Origin: *; *
  X-Sourcefiles: =?UTF-8?B?RDpcU291cmNlc1xHcmFwcHNcVUtfQnJhbmRQcm90ZWN0aW9uXFdlYkFQSVxhcGlcTG9naW4=?=
  X-Powered-By: ASP.NET
  Access-Control-Allow-Headers: Content-Type
  Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
  Date: Thu, 04 Aug 2016 11:59:19 GMT
  Content-Length: 316
  </code></pre>