文档
https://review.gerrithub.io/Documentation/rest-api.html
{gerrit_url}/Documentation/rest-api.html
除了内置的API,有些插件也会提供API,需要到具体的插件详情页查看其API。(或者通过github查看具体插件源码中的README.md或者src/main/resources/Documentation/)
认证机制
https://review.gerrithub.io/Documentation/rest-api.html#authentication
默认情况下,所有 api 都假定匿名访问,所以只能访问公开的内容。可以通过在 api 的URL前面加上 /a
来启用身份验证,认证方式为HTTP BASIC 认证。
例如:请求 /projects/ 只能访问到公开的项目,要获取用户可访问的项目,则要请求 /a/projects/
curl --user username:password http://localhost:8080/a/projects/
password并不是登录web时的密码,而是在个人设置中生成的 HTTP密码。
API返回体
https://review.gerrithub.io/Documentation/rest-api.html#output
有些API返回体可能携带 )]}'
前缀(为防止css/xss攻击)
)]}'
... valid JSON ...