Doing a request from the fetch api to the endpoint and the props do not bind.
The id and fileName are 0 and null respectively on the endpoint.
My fetch:
fetch(`https://localhost:44343/items/edit`, {
method: 'POST',
mode: 'cors',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
body: JSON.stringify({
id:123,
fileName:"asd"
})
})
.then(response => console.log(response))
.catch(error => console.error('Unable to update item.', error));
My endpoint:
[HttpPost]
public async Task<IActionResult> Edit([FromBody]int id, string fileName)
{
return Ok(id);
}
The request payload shows that the values are being sent:
I've tried using and not using the [FromBody] adding explicitly the route to the action, changing to PUT instead of POST (why the heck does the default for the update action is a POST??)
Anything else I can try?
