My REST API is configured to accept this kind of request
public function lockUserAction($slug)
{} // "lock_user" [PATCH] /users/{slug}/lock
So sending a patch request to
/api/users/2/lock
Will lock the user with id=2. This is my rest service inside angular.js
angular.module('UserService',['ngResource']).factory('User', function($resource){
var User = $resource('/api/users/:id',
{},
{
list: { method: 'GET' },
lock: { method: 'PATCH' }
}
);
return User;
});
List works just finde, but lock does not work. The console prints:
PATCH /api/users 405 (Method Not Allowed)
I invoke it like this
$scope.lock = function(user){
user.$lock();
}
In the error message I see the url /api/users instead of /api/users/2/lock. Is this normal behaviour? Of course list excepts only GET requests and PATCH requests are not allowed on /api/users only on /api/users/{slug}/lock.
Any ideas why /api/users is called and not /api/users/{slug}/lock. Any ideas how to fix this?
PATCHused for ajax requests... inspect actual request in browser console or fiddler and see what method is being sent, and what url is being used