I have two or more get methods in web api, (as per below give code GetProducts and GetProductsNew are get methods). As i am using the ng-resource of angular js, whenever i try to call get function, it is giving an ambiguous error. Suppose i want to call GetProductsNew method then how can i call? Can anyone help please, thanks in advance :)
// This is my web api code
public class ProductController : ApiController
{
...
public HttpResponseMessage GetProducts()
{
}
public HttpResponseMessage GetProductsNew()
{
}
}
// **This is my angular**
// This is the code in controller.js, using which i am calling the get method from above code, but here the problem is, since the above web api is having the two gt method, i am getting the "Multiple actions were found that match the request"
productcatControllers.controller('ProductListCtrl', ['$scope', '$routeParams',
'$location', '$route', 'productService',
function ($scope, $routeParams, $location, $route, productService)
{
productService.query(function (data) {
$scope.products = data;
});
}]);
// This is the service of angular js
var phonecatServices = angular.module('productcatServices', ['ngResource']);
phonecatServices.factory("productService", function ($resource) {
return $resource(
"/api/Product/:id",
{ id: "@id" },
{
"update": { method: "PUT" }
}
);
});