title: Angular2. Http. Can't send post with body and set Content-Type
body: <p>I'm writing an app with using Angular2 as a front-end part(~2.4.0) and ASP.NET CORE as a back-end part.</p>
  
  <p>I have a really huge problem with sending a post request. Chrome tells me that i have no body in request and also I can't set up content-type of request.</p>
  
  <p>I tried in a few ways. But no one worked </p>
  
  <pre><code>         let headers = new Headers();
           headers.append('Content-Type', 'application/json');
           headers.append('authentication', `3123123123`);
  
           let options = new RequestOptions({ headers: headers });
           this.http
           .post('http://localhost:5000/api/user/login', JSON.stringify(this.loginModel), options)
           .subscribe((result) =&gt; {
                       if (result) {
                           .......
                       }
                   });
  </code></pre>
  
  <p>Second:</p>
  
  <pre><code>PostRequest(url:string,data:any) {
      var headers = new Headers();
      headers.append("Content-Type", 'application/json');
  
      var requestoptions = new RequestOptions({
          method: RequestMethod.Post,
          url: url,
          headers: headers,
          body: JSON.stringify(data)
      })
  
      return this.http.request(new Request(requestoptions))
          .map((res: Response) =&gt;
          res.json()
      ).subscribe((result) =&gt; {
              if (result) {
                  ....
              }
          });
  }
  </code></pre>
  
  <p>Third one:</p>
  
  <pre><code>    let headers = new Headers();
      headers.append('Accept', 'application/json');
      headers.append('Content-Type', 'application/json');
  
  
      let body = JSON.stringify(loginDto);
      let options = new RequestOptions({headers: headers});
  
      return this.http
          .post(
              '....',
              body,
              options
          )
          .map(res =&gt; res.json()).subscribe((result) =&gt; {
              if (result) {
                  ....
              }
          });
  </code></pre>
  
  <p>UPD:</p>
  
  <p>I've tried @Akshay Khale method and It still doesn't work. I still get headers with out content type</p>
  
  <p><a href="https://i.stack.imgur.com/GmIOn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GmIOn.png" alt="Headers of request"></a></p>
  
  <p>RESOLUTION:</p>
  
  <p>The problem was in a back-end side. CORS-configuration had been made in a wrong way. And ASP.NET CORE blocked all custom headers. Thank everyone for help</p>