Sign up ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.

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!

share|improve this question
    
Can you show what you mean by "doesn't make the correct call". Maybe post the error you're seeing in your browser debug tool? –  stormlifter Sep 27 '13 at 14:03
    
there is no error, by incorrect call I mean that for #1 I am trying to send params as request payload and it is sending by query string, similar for #2 –  Mohammad Umair Khan Sep 30 '13 at 4:58

1 Answer 1

up vote 17 down vote accepted

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.

share|improve this answer
    
alright .. i m not on my work machine now, and its weekend here. Ill accept the answer once I test it on monday :) –  Mohammad Umair Khan Sep 27 '13 at 19:52
2  
Why does the patch function accept an object and not the put function. It seems a bit inconsistent. –  CMCDragonkai Mar 6 '14 at 20:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.