Mohsin
Mohsin

Reputation: 902

Passing 2 parameters to $http.post return error 404

I am trying to pass 2 value to the function in RestAPI through $http.post method when the $http.post method is called browser console shows error

http://localhost:8550/api/Servicesapi/UpdateEmployeeServices/ 404 (Not Found) 

But when i pass single value function executes successfully and no error is shown

here is my Angular Code

var servicedata = JSON.stringify($scope.services);
var sdata = { id: Id, services: servicedata };
$http.post('/api/Servicesapi/UpdateEmployeeServices', sdata)
.then(function (result) {
//Success
  }, function() {
//Error
});

Here is API Function

[AcceptVerbs,HttpPost]
public void UpdateEmployeeServices(string id,Service[] services)
{
     //some Implementation       
}

Upvotes: 0

Views: 554

Answers (1)

Nix
Nix

Reputation: 58522

I think your solution is(based on a major asumption that your route is actually UpdateEmployeeSrvices/<id>):

//var servicedata = JSON.stringify($scope.services);
//var sdata = { id: Id, services: servicedata };
$http.post('/api/Servicesapi/UpdateEmployeeServices/'+ Id , $scope.services)
   .then(function (result) {
     //Success
   }, function() {
      //Error
})

Upvotes: 1

Related Questions