Angular2 - HTTP RequestOptions HEADERS

Solution 1:

Update

As of today, @angular/http has been deprecated, and @angular/common/http should be used instead. So the best way to work with http headers is to import import { HttpHeaders } from '@angular/common/http'; (documentation).

Old answer

The Headers type you are supposed to import is import { Headers } from '@angular/http';.

Check your imports

Solution 2:

You have to update headers by:

let headers =  {headers: new  HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded'})};

Solution 3:

Update for Angular 5

import { RequestOptions } from '@angular/http';

I found this in the comments from the correct answer, so If this helps somebody, good luck.

Documentation: https://angular.io/api/http/RequestOptions