I have problem in Fetch POST to controller, an showing error like {"errors":{"":["Unexpected character encountered while parsing number: W. Path '', line 1, position 6."]},"title":"One or more validation errors occurred.","status":400,"traceId":"0HLOGKVEBUTKL:00000007"}. When I debbug too, in my controller it's not passing to controller.
This what I POST to
I'm using ReactJs for client-side, and Net Core for server-side. Here my code snippet:
AddList.js
fetch('api/SampleData/AddEmployee', {
method: 'POST',
headers: {
'Accept': 'application/json; charset=utf-8',
'Content-Type': 'application/json;charset=UTF-8'
},
body: data,
}).then((response) => response.json())
.then((responseJson) => {
console.log('Success:', JSON.stringify(responseJson));
this.props.history.push("/list-data");
})
.catch(error => console.error('Error:', error));
SampleDataController.cs
[HttpPost("[action]")]
public JsonResult AddEmployee(EmployeesViewModel employee)
{
}
starrup.cs
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
routes.MapRoute(
name: "api",
template: "api/{controller}/{action}/{id?}");
});


Content-Type. It worked for me when i was dealing with formdata{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.13","title":"Unsupported Media Type","status":415,"traceId":"0HLOGKVEBUTKP:00000008"}Unsupported Media Type @mkamranhamid'Content-Type': 'multipart/form-data'