Problem with the sending of paramaters to rbv_api.sendhttpPo

Posted by Kobe_mamba on 08-Jun-2014 04:56

Hi .

How do i send the header information like headers for authorization...I tried sending it in header={"Authorization " : "......"} format ...but i am recieving errors...Should i be sending in key value pair itself or does Oauth require some other format.... I have also seen some others having the same problem...but with paypal api...

And also I have tried to write the ajax request as i did'nt know the inner mechanism of the rbv_api calls....But jt has difficulty requesting(GET,POST) apis for security reasons.. No 'Access-Control-Allow-Origin' is the errror if i am using manual javscript rather than using rbv_api calls....

Please help me with the rbv_api calls or the manual ajax calls 

My code

var url="https://api.twitter.com/1.1/statuses/update.json";
var params={"status":"Hiii"};
var key="OAuth oauth_consumer_key=/"ydpaKblD5OKK3kW2TRuscej1P/", oauth_nonce=/"539c9b13e0e76f4bfdb4f1c462ff97d7/", oauth_signature=/"oaOSVDDvx3EfUPRCunZU%2FHkqir0%3D/", oauth_signature_method=/"HMAC-SHA1/", oauth_timestamp=/"1402394771/", oauth_token=/"581185549-BeGt5lT3dIFSHHD9vll4tYkazpPgpGaj1Fixl3ki/", oauth_version=/"1.0/" ";
var headers={
"content-Length":params.length,
"content-Type":"jsonp",
"Connection":"close"
"Authorization":key
};

var body=rbv_api.sendHttpPost(url,params,headers);


rbv_api.setSharedValue("response",body);
var json=rbv_api.stringToJson(body);

return body;

Plss help :)

All Replies

Posted by murali on 10-Jun-2014 11:53

From Rollbase in Action, Chapter 6
 
 
var url = "http://my_server/login";
var params = {"loginName":"my_name", "password":"my_password"};

var headers = {  ‘header_name1’ :  ‘header_val1’,        ‘header_name2’ :  ‘header_val2’  }      

 
var resp = rbv_api.sendHttpPost(url, params, headers, false);  //   specify the last param chunked=false.   Else the request is sent as chunked. Some servers do no accept chunked encoded  requests.
rbv_api.println(resp);
 
[collapse]
From: Kobe_mamba [mailto:bounce-Kobe_mamba@community.progress.com]
Sent: 08 June 2014 15:27
To: TU.Rollbase@community.progress.com
Subject: [Technical Users - Rollbase] Problem with the sending of paramaters to rbv_api.sendhttpPost()..headers key value pairs problem...
 
Thread created by Kobe_mamba

Hi .

How do i send the header information like 

Authorization:  OAuth oauth_consumer_key="ydpaKblD5OKK3kW2TRuscej1P", oauth_nonce="7b4b93e333638f075579f7665bb3a3b2", oauth_signature="O9p9WxPW5cSfPmpam8RC8W5M0C0%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1402218095", oauth_token="581185549-BeGt5lT3dIFSHHD9vll4tYkazpPgpGaj1Fixl3ki", oauth_version="1.0"

I tried sending it in header={"Authorization " : "......"} format ...but i am recieving errors...Should i be sending in key valu epair itself or does Oauth require some other format....

My code

var url="https://api.twitter.com/1.1/statuses/update.json";
var params={"status":"Hiiiiii"};
var headers={"Authorization":"OAuth oauth_consumer_key="ydpaKblD5OKK3kW2TRuscej1P", oauth_nonce="7b4b93e333638f075579f7665bb3a3b2", oauth_signature="O9p9WxPW5cSfPmpam8RC8W5M0C0%3D", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1402218095", oauth_token="581185549-BeGt5lT3dIFSHHD9vll4tYkazpPgpGaj1Fixl3ki", oauth_version="1.0" "};

var body=rbv_api.sendHttpPost(url,params,headers);

Plss help :)

Stop receiving emails on this subject.

Flag this post as spam/abuse.

[/collapse]

Posted by Kobe_mamba on 11-Jun-2014 04:24

Hi,

Thanks for the reply..But the last param "chunked =false" is also not helping...

I am getting the error " HTTP call failed: Bad Request "

Does the rbv_api.sendhttpPost call  support CORS("Cross-origin resource sharing") ?? becuase that was the error i was getting when i wrote manual ajax script (I got the error "No access control origin")

Posted by cprak on 12-Jun-2014 10:25

Hello Kobe_mamba,

just wanted to inform you that I'm actively looking into a solution. First of all, have you successfully been able to use the Twitter API externally? Knowing so will help to determine whether the issue is more related to Rollbase or not.

Unfortunately, javascript is limited by the same-origin policy which explains the error message you received ("No access control origin"). CORS support requires the particular header (Access-Control-Allow-Origin) to be mentioned for both clients and servers. At this point it seems that Twitter does not provide CORS support.

Thanks, 

Corey Prak

This thread is closed