The (Angular) code I'm trying to execute looks like this:
this.http.post(url, formData, httpOptions).subscribe(
(data) => {
console.log(data);
},
(error) => {
console.log(error);
});
The formData is simply:
const formData = new FormData();
formData.append('listNetworkConstituents', JSON.stringify(params));
Tried lots of options including:
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/x-www-form-urlencoded'
})
}
I've validated params data and Json isn't having any trouble with it. Fiddler confirms the request gets to the server and then is rejected: "server responded with a status of 415 (Unsupported Media Type)"
I know use of FormData is working elsewhere against this server.
Any ideas? Thanks in advance. Yogi
The HTTP 415 Unsupported Media Type client error response code indicates that the server refuses to accept the request because the payload format is in an unsupported format.
The format problem might be due to the request's indicated Content-Type or Content-Encoding, or as a result of inspecting the data directly.
Above excerpt is from: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/415
Please compare the content-type and content-encoding in your header and make sure that the URL that is listening to this call is expecting the type you are sending.
Things you can do