1

I can't change Content-Type to application/json in headers of post request. I use angular 6. Request is rejected with error (Unsupported Media Type) Same request working with old http from '@angular/http'.

I use visual studio debug for running application. Web api is .net core.

import { HttpClient, HttpRequest, HttpEventType, HttpResponse, HttpHeaders 
} from '@angular/common/http';

var body = JSON.stringify(model);
let headers = new HttpHeaders();
headers = headers.set('Content-Type', 'application/json');

let httpOptions = {headers: headers,};

this.http.post(this.Url, body, httpOptions).subscribe(x => { })

Request result

1

1 Answer 1

0

Solution: I used HttpInterceptor which replace request headers

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.