I am sending an array of integers to the web api controller method successfully using angularjs $resource custom method without params defined. When I add other parameters with an array type parameter and define it in $resource custom method then other parameters are received successfully but the array found null. Here is the code with only array that is working fine. AngularJS Service
var Product_Service = $resource('api/Product/:productId', { productId: '@id' },
{
'update': { method: 'PUT' },
'bulkDelete': {
method: 'POST',
url: 'api/Product/BulkDelete',
isArray:true
}
}
Calling it like this (passing directly the array):
bulkDelete: function (productIds) {
var deferred = $q.defer();
Product_Service.bulkDelete(productIds, function (response) {
deferred.resolve(response);
}, function (response) {
deferred.reject(response);
});
return deferred.promise;
},
Server side:
[Route("BulkDelete")]
public HttpResponseMessage BulkDelete(int[] ProductIds)
{
return Request.CreateResponse(HttpStatusCode.OK);
}
Problem: I want to receive this array with another parameter but in that case array is received with value null.
[Route("BulkDelete")]
public HttpResponseMessage BulkDelete(int[] ProductIds,string hi)
{
//now ProductIds is null with another string hi parameter
return Request.CreateResponse(HttpStatusCode.OK);
}
angularjs service:
'bulkDelete': {
method: 'POST',
url: 'api/Product/BulkDelete',
isArray:true,
params:{
productIds:'@productIds',
hi:'@hi'
}
}
Now m calling like this,
bulkDelete: function (productIds) {
var deferred = $q.defer();
Product_Service.bulkDelete({productIds:productIds,hi:'hi how'}, function (response) {
deferred.resolve(response);
}, function (response) {
deferred.reject(response);
});
return deferred.promise;
},
Where is the problem and is that possible? If yes where I need to amend?