When attempting to perform a simple AJAX PUT operation on my API method, I found that the parameters were not being set and remained as 0. This occurred despite the request reaching the API method without any errors. What could be causing this issue?
AJAX Call:
var data = {
productId: 100,
oldIndex: 3
};
$.ajax({
url: '/api/products/reorder',
method: 'PUT',
data: JSON.stringify(data),
contentType: 'application/json'
});
API:
[HttpPut("api/products/reorder")]
public IActionResult ReOrder([FromBody]int productId, [FromBody]int oldIndex)
{
}