I am trying to consume an API that only accepts 'POST' requests for this case and when I make the request it gives me a 400 with the error:
"httpErrorMessage":"Bad Request","message":"Method not supported: Request method 'POST' not supported"
Any idea where the problem may be?
My service.
private urlApi= 'http://localhost:8080/api';
updateIt(id: string, lang: string, body: Object) {
let bodyString = JSON.stringify(body);
let headers = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' });
let options = new RequestOptions({ headers: headers });
return this.http.post(this.copiesUrl + "/" + id + "/lang/" + lang, body, options)
.map((res:Response) => res.json())
.subscribe(
data => console.log('Success update ', data),
error => console.error('Error: ${error}')
);
}
Greetings and thank you.
I think the error is that the endpoint you are invoking does not support this method. Same thing if you do it with a PUT or a GET, but POST doesn't seem to support it.
To be safe I would try invoking directly using a Rest client and see if you get the same error. If so, either you are calling the wrong url or the server is not well implemented.