I have a web api method like below:
/// <summary>
/// DELETE: api/ftpapi/custom/deletefiles
/// </summary>
/// <param name="items"></param>
/// <returns></returns>
[HttpDelete]
[ResponseType(typeof(void))]
public IHttpActionResult DeleteFiles(string[] items)
{
return Ok();
}
In my view I call this method using Ajax:
var values = $('input:checkbox[name=items]:checked').map(function () {
return this.value;
}).get();
$.ajax({
url: uri_api + '/custom/deletefiles',
method: "DELETE",
data: { items: values }
}).done(function (data) {
location.reload(true);
})
.fail(function (jqXHR, textStatus, err) {
console.log('Error: ' + err);
})
.always(function () {
$('#loader').fadeOut(200);
$('body').removeClass('loader-in');
});
When I place a breakpoint at the return Ok(); and test this out, it works. Except the param string[] items is always empty.
If I look into the network tab of Google Chrome I can see the items in my form data:
What am I missing here?

values? And setcontentType: 'application/json'data: JSON.stringify({ items: values })nullinstead of an empty array