title: Upgrade Http to HttpClient in Angular 5: "server responded with a status of 415 (Unsupported Media Type)"
body: <p>I've upgraded an app from Angular 4.2 to 5 but after changed <code>Http</code> to <code>HttpClient</code> got error on POST request: </p>
  
  <blockquote>
    <p>error the server responded with a status of 415 (Unsupported Media
    Type)</p>
  </blockquote>
  
  <p>in <code>app.module</code> I've imported <code>HttpClientModule</code>:</p>
  
  <pre><code>import { HttpClientModule } from '@angular/common/http';
  </code></pre>
  
  <p>Old code:</p>
  
  <pre><code> post(url: string, model: any): Observable&lt;any&gt; {
          let body = JSON.stringify(model);
          let headers = new Headers({ 'Content-Type': 'application/json' });
          let options = new RequestOptions({ headers: headers });
          return this._http.post(url, body, options)
              .map((response: Response) =&gt; &lt;any&gt;response.json())
              .catch(this.handleError);
      }
  </code></pre>
  
  <p>new code:</p>
  
  <pre><code>put(url: string, id: number, model: any): Observable&lt;any&gt; {
          let body = JSON.stringify(model);
          let headers = new Headers({ 'Content-Type': 'application/json' });
          let options: any = new RequestOptions({ headers: headers });
          return this._http.put(url + id, body, options)
              .catch(this.handleError);        //only removed .map
      }
  </code></pre>
  
  <p>thanks</p>