I didn't realise you were trying to post a review. Does post-review
(bundled with RBTools) not help you? If not, why?
On Tuesday, 26 February 2013 16:45:43 UTC+8, cmuser wrote:
Thanks. I will try follow it.
What i did is , tried writing the script(mentioned above) to post a review
request which is failing of xyz reason. So thought of using HTTP::Recorder
to get the script of posting a review request. But again facing issues in
that.
curl command which worked once -
curl -k -H Basic YWRtaW46YWRtaW4= -X POST -d {\repository_id\:
cvsrepo,\repository_path\::pserver:kapila:kapila123@svn:/opt/cvsroot,\username\:kapila,\password\:kapila123,\submit-as\:kapila}
http://codereview.xyz.com/r/new
Would be great if you can share your script to give quick better
understanding.
On Tuesday, February 26, 2013 2:08:54 PM UTC+5:30, Gavin Main wrote:
After a bit of fiddling and research I found that the LWP and
HTTP::Cookies modules worked for me. Have a look at the documentation on
CPAN
http://search.cpan.org/~gaas/HTTP-Cookies-6.01/lib/HTTP/Cookies.pm
This link was also very helful:
http://lwp.interglacial.com/ch11_01.htm
Basically I wanted my post-commit hook to close out an associated review
on Reviewboard. So I wrote two subroutines to do that. The first generated
the cookie:
- create the cookie file
- issue the get request with HTTP::Request
- authenticate with authorization_basic
- extract the cookie
- return hash
Then I passed the cookie hash to another subroutine which issued my PUT
request with the information inside the cookie hash.
Cheers,
Gavin
On Monday, 25 February 2013 21:25:13 UTC+8, cmuser wrote:
i have tried to built like this,but still not working
#!/usr/local/bin/perl
use LWP::UserAgent;
use MIME::Base64;
$url=http://codereview.xyz.com/api/review-requests/;;
$newurl=http://codereview.xyz.com/r/new/;;
$user=admin;
$pwd=admin;
$text=$user:$pwd;
$text = encode_base64($text);
#print Encoded text: $text\n;
%param =(
repository_id =cvsrepo,
repository_path =:pserver:user:pwd\@svn:/opt/cvsroot,
username = admin,
password = admin,
submit-as = username,
);
my $ua = LWP::UserAgent-new;
$ua-timeout(TIMEOUT);
$ua-protocols_allowed(['http', 'https']);
$ua-default_header('Basic' = $text);
$ua-credentials($newurl,$user,$pwd);
$resp = $ua-get($url);
print($resp-status_line(), \n);
print(Add handler:\n);
$ua-add_handler( response_header = sub { print HANDLER\n; },
%param);
print $ua-handlers('response_header', $resp).\n;
push @{ $ua-requests_redirectable }, 'POST';
print $ua-show_progress.\n;
my $response = $ua-post($newurl,%param);
if ($response-is_success) {
print $response-decoded_content;
}
else {
die $response-status_line;
}
On Friday, August 10, 2012 2:56:12 PM UTC+5:30, Gavin Main wrote:
Hi Jeff, did you ever get this resolved? I am facing a similar issue.
Christian, I am loving Reviewboard. Thank You!!!
Cheers,
Gav
On Friday, 22 October 2010 02:06:16 UTC+8, Jeff wrote:
I'm trying to write an svn pre-commit hook against a totally new
installation of reviewboard 1.5 (upgraded from the previous version,
but never really used).
As far as I can tell from the documentation, the json login page isn't
used anymore, and I just use basic HTTP authentication.
My perl code looks like this:
#!/usr/bin/perl
use LWP::UserAgent;
my $ua = LWP::UserAgent-new;
#$ua-credentials($rbhost:80,Web API,'user' = 'password');
my $req = HTTP::Request-new(GET = http://reviewboard.local.com/
rboard/api/review-requests/93/last-update/http://reviewboard.local.com/rboard/api/review-requests/93/last-update/);
$req-authorization_basic('user', 'password');
my $res = $ua-request($req);
print $res-as_string;
I've tried both the useragent credential and the request-
authorization_basic.
The result I get back is:
HTTP/1.1 401 UNAUTHORIZED
Cache-Control: max-age=0
Connection: close
Date: Thu, 21 Oct 2010 17:53:43 GMT
ETag: 3818aa0b0928af747aebc006814783fe
Server: Apache/2.2.3 (CentOS)
Vary: Cookie,Accept-Language
WWW-Authenticate: Basic realm=Web API
Content-Language: en-us
Content-Length: 70
Content-Type: application/json
Expires: Thu, 21 Oct 2010 17:53:43 GMT
Last-Modified: Thu, 21 Oct 2010 17:53:43 GMT
Client-Date: Thu, 21 Oct 2010 17:53:43 GMT
Client-Peer: 10.20.30.183:80
Client-Response-Num: 1
{stat: fail, err: {msg: You are not logged in, code: 103}}
If I try and hit the same page in an web browser after authenticating,
I get a 500 error and an email post at the end of this message.
What am I doing wrong? Is there any example perl code that hit's the
new API? I assume the existing stuff that I'm finding on the net
won't work anymore.
Traceback (most recent call last):
File /usr/local/reviewboard/python