I am trying to post an array of integers to delete from a service using $http to ASP.Net Web API controller method. I have tried both
[HttpDelete]
public HttpResponseMessage DeleteMany(int[] ids) { }
[HttpDelete]
public HttpResponseMessage DeleteMany(DeleteManyDto dto) { }
public class DeleteManyDto
{
public int[] Ids {get;set;}
}
I keep getting the params as null. I have tried a couple of variations in the Angular service. Here is an example
this.deleteMany = function(ids) {
// ids is an int array. e.g. [1,4,6]
return $http.delete('api/Foo/DeleteMany', { toDelete: ids }).then(function(result) {
return result.status;
});
};
Anyone know what I could be missing?
UPDATE: Spelling mistake. Included debug from HTTP request.
Request URL:http://localhost:54827/api/Foo/DeleteMany
Request Method:DELETE
Status Code:500 Internal Server Error
Request Headersview source
Accept:application/json, text/plain, */*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Cookie:__RequestVerificationToken=blabla
Host:localhost:54827
Origin:http://localhost:54827
Pragma:no-cache
Referer:http://localhost:54827/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
Response Headersview source
The code above is not producing any request payload. When I do an update I see the request payload. Example
Request Payloadview parsed
{"id":4,"name":"zzzz", "bar": 2}
For what it is worth I am using Angular 1.2.rc3