I'm having an issue with my body parameter being always null. Here's the controller:
[HttpPost]
public async void Assign([FromUri] int[] sectionIds, [FromBody] int[] ids) ...
The URI parameter is filled out. However, The Body parameter is always empty.
Here's the ajax request:
return $.ajax(
{
url: api_url,
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
"ids": ids
})
})
Here's what I see in the payload on in my network monitor.
{"ids":[597,1893]}:
What's could be the problem here?
EDIT: I'm using an API Controller
It seems that URL is not in correct place. Could you try the following with contentType?
$.ajax({
url: API_URL,
contentType: "application/json",
method: "POST",
data: JSON.stringify({"ids": ids},
success: function(result) { return result; }
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With