Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PUT/GET with Payload using Restangular

I am using Restangular in one of my works

The server guys have give me the following calls which i need to integrate on the AngularJS client

  1. PUT api/partners/password – RequestPayload[{password,confirmpassword}] partner id is being sent in the header

  2. GET api/partners/password/forgot/ - Request Payload [{emailaddress}] partner id is being sent in the header

The javascript code that I have written to call these services is as follow

  1. Restangular.all('Partners').one('Password').put(params); - sends params as query string
  2. Restangular.all('Partners').one('Password').one('Forgot').get(params); - sends object in the url

I have tried other ways but it simply doesn't make the correct call.

Help me out guys!

like image 306
Mohammad Umair Khan Avatar asked Sep 27 '13 12:09

Mohammad Umair Khan


1 Answers

So, for point #1. it puts the object at hand, not another object. So you have 2 options:

Option 1

var passReq = Restangular.all('Partners').one('Password');
passReq.confirmPassword = ....
passReq.put(); // confirmPassword and the params of the object will be sent 

Option 2 is

var passReq = Restangular.all('Partners').one('Password').customPUT(obj);

For Point #2, you cannot send a request body (payload) in the GET unfortunately.

like image 145
mgonto Avatar answered Nov 13 '22 04:11

mgonto