asp.net web api - Angular $resource WebAPI FromBody Clarification -
i have webapi controller defined this
[route("~/api/v1/employees/{id}")] [httpget] public httpresponsemessage getemployee([frombody]int empid) { var emp = db.employees.firstordefault(i => i.empid == empid) employee; return request.createresponse<employee>(httpstatuscode.ok, emp); }
here angular controller call method , angular service
controller:
$scope.employee = empfactory.singleemployee.query({ id: sharedata.value }, { empid: 2 } , function (data) { emp = data; });
service:
singleemployee: $resource('/api/v1/employees/:id', { id: '@id'}, { query: { method: 'get' } } )
note: have purposefully changed parameter name empid in webapi controller understand how call such methods angular..
question 1: doesn't work.. fiddler, clear empid not getting passed while request
question 2: per documentation, need pass data/params $resource method in case m passing parameter through controller method without specifying directly in $resource.. how work? sorry if silly question
i think supposed tag [fromuri], implies variable set in url.
Comments
Post a Comment