How do I not send url template parameters with request body in angular? How do I not send url template parameters with request body in angular? angularjs angularjs

How do I not send url template parameters with request body in angular?


Use the first parameter for your url template parameters and put your post data in the second parameter like this:

resource.save({id:14, type:'user'}, {name:'Bob Dole'});

Here's the line from the Angular docs that shows the function signature:

non-GET "class" actions: Resource.action([parameters], postData, [success], [error])

Here's an example in plunker

The request you get does not have the url parameters in the body:

Request URL:http://run.plnkr.co/JAOqZqW6RSywatUM/badUrl/user/14Request Method:PUTRequest Payloadview source{name:Bob Dole}


FWIW, I did find a workaround, thanks to @Reboog711, by including a transformRequest parameter like so:

resource = $resource(    "http://foo.com/service/:type/:id",    {},    {save: {        method:'PUT',         transformRequest:function(data) {            delete data.type;            delete data.id;            return JSON.stringify(data);        },        params: {type:'@type', id: '@id'}    }});