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/");
$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/Django-1.2.1-py2.7.egg/django/
core/handlers/base.py", line 100, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/reviewboard/python/Django-1.2.1-py2.7.egg/django/
views/decorators/cache.py", line 70, in _wrapped_view_func
add_never_cache_headers(response)
File "/usr/local/reviewboard/python/Django-1.2.1-py2.7.egg/django/
utils/cache.py", line 116, in add_never_cache_headers
patch_response_headers(response, cache_timeout=-1)
File "/usr/local/reviewboard/python/Django-1.2.1-py2.7.egg/django/
utils/cache.py", line 105, in patch_response_headers
response['ETag'] = '"%s"' %
md5_constructor(response.content).hexdigest()
File "/usr/local/reviewboard/python/Djblets-0.6.4-py2.7.egg/djblets/
webapi/core.py", line 273, in _get_content
content = adapter.encode(self.api_data, request=self.request)
File "/usr/local/reviewboard/python/Djblets-0.6.4-py2.7.egg/djblets/
webapi/core.py", line 119, in encode
self.__encode(o, *args, **kwargs)
File "/usr/local/reviewboard/python/Djblets-0.6.4-py2.7.egg/djblets/
webapi/core.py", line 136, in __encode
self.__encode(value, *args, **kwargs)
File "/usr/local/reviewboard/python/Djblets-0.6.4-py2.7.egg/djblets/
webapi/core.py", line 136, in __encode
self.__encode(value, *args, **kwargs)
File "/usr/local/reviewboard/python/Djblets-0.6.4-py2.7.egg/djblets/
webapi/core.py", line 164, in __encode
return self.__encode(result, *args, **kwargs)
File "/usr/local/reviewboard/python/Djblets-0.6.4-py2.7.egg/djblets/
webapi/core.py", line 136, in __encode
self.__encode(value, *args, **kwargs)
File "/usr/local/reviewboard/python/Djblets-0.6.4-py2.7.egg/djblets/
webapi/core.py", line 162, in __encode
raise TypeError("%r is not XML serializable" % (o,))
TypeError: 2L is not XML serializable
<WSGIRequest
GET:<QueryDict: {}>,
POST:<QueryDict: {}>,
COOKIES:{'csrftoken': '3c25a25c4c6ced636686afac7a25a4f1',
'rbsessionid': '2aeedaf117ffddcef6c72c0d5a2a407b'},
META:{'DOCUMENT_ROOT': '/usr/local/reviewboard/web/htdocs',
'GATEWAY_INTERFACE': 'CGI/1.1',
'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/
xml;q=0.9,*/*;q=0.8',
'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'HTTP_ACCEPT_ENCODING': 'gzip,deflate',
'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',
'HTTP_CONNECTION': 'keep-alive',
'HTTP_COOKIE': 'rbsessionid=2aeedaf117ffddcef6c72c0d5a2a407b;
csrftoken=3c25a25c4c6ced636686afac7a25a4f1',
'HTTP_HOST': 'reviewboard',
'HTTP_KEEP_ALIVE': '115',
'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10',
'PATH': '/sbin:/usr/sbin:/bin:/usr/bin',
'PATH_INFO': u'/rboard/api/review-requests/93/last-update/',
'PATH_TRANSLATED': '/usr/local/reviewboard/web/htdocs/
reviewboard.fcgi/rboard/api/review-requests/93/last-update/',
'QUERY_STRING': '',
'REMOTE_ADDR': '10.20.68.52',
'REMOTE_PORT': '3620',
'REQUEST_METHOD': 'GET',
'REQUEST_URI': '/rboard/api/review-requests/93/last-update/',
'SCRIPT_FILENAME': '/usr/local/reviewboard/web/htdocs/
reviewboard.fcgi',
'SCRIPT_NAME': u'',
'SCRIPT_URI': '
http://reviewboard/rboard/api/review-requests/93/last-
update/',
'SCRIPT_URL': '/rboard/api/review-requests/93/last-update/',
'SERVER_ADDR': '10.20.30.183',
'SERVER_ADMIN': 'root@localhost',
'SERVER_NAME': 'reviewboard',
'SERVER_PORT': '80',
'SERVER_PROTOCOL': 'HTTP/1.1',
'SERVER_SIGNATURE': '<address>Apache/2.2.3 (CentOS) Server at
reviewboard Port 80</address>\n',
'SERVER_SOFTWARE': 'Apache/2.2.3 (CentOS)',
'wsgi.errors': <flup.server.fcgi_base.OutputStream object at
0x197b4c50>,
'wsgi.input': <flup.server.fcgi_base.InputStream object at
0x197b4910>,
'wsgi.multiprocess': False,
'wsgi.multithread': True,
'wsgi.run_once': False,
'wsgi.url_scheme': 'http',
'wsgi.version': (1, 0)}>