I am trying to post data from Angular4 on localhost:4200 to an API on localhost:8000. I works fine with Postman, but not with Angular. Then I get:
Failed to load resource: the server responded with a status of 422 (Unprocessable Entity)
This is the service that posts to api:
This is the code that runs the method
logIn(user: string, password: string){
this.apiService.login(user, password).subscribe(
data => console.log(data),
error => console.log(error)
);
}
The 422 (Unprocessable Entity) status code means the server understands the content type of the request entity (hence a 415(Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions.
For example, this error condition may occur if an XML request body contains well-formed (i.e., syntactically correct), but semantically erroneous, XML instructions.