Gerrit - REST API

119 views
Skip to first unread message

Guy Levkowitz

unread,
Feb 3, 2022, 4:50:50 AM2/3/22
to Repo and Gerrit Discussion
Hi,

We are trying to work with the Rest API of Gerrit (version 3.3.3):
Documentation/rest-api.html

In small cases i get reply and it works fine for example :
{SERVER}/config/server/version
we are using via postman
Attached is the output of this get request

But in most cases for example :
{SERVER}/changes/?q=status:merged 
we get attachment

the question why ? 

BR

Guy Levkowitz



 
Gerrit_REST_API_POSTMAN_NOT_WORKS.jpg
Gerrit_REST_API_POSTMAN_WORKS.jpg

Luca Milanesio

unread,
Feb 3, 2022, 4:58:48 AM2/3/22
to Repo and Gerrit Discussion, Luca Milanesio, Guy Levkowitz
That is just an information for the browser, for avoiding the online rendering of the content.
If you are using the REST-API from your code, you can ignore it for the API returning JSON.

The changes query may return a very big JSON content, that’s why it is better to tell the browser to download the data instead of rendering it.
Other API have a small JSON, so where you render it really doesn’t matter.

See more insights on the Content-Disposition at [1].

P.S. Avoid screenshots and prefer textual output as example, it makes it easier to follow.

HTH

Luca.



BR

Guy Levkowitz



 

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/repo-discuss/b3da2d91-cb93-4d78-b9bd-a920bf38bfc1n%40googlegroups.com.
<Gerrit_REST_API_POSTMAN_NOT_WORKS.jpg><Gerrit_REST_API_POSTMAN_WORKS.jpg>

Edwin Kempin

unread,
Feb 3, 2022, 5:00:36 AM2/3/22
to Guy Levkowitz, Repo and Gerrit Discussion
Both your requests are anonymous. Likely the second request doesn't return any changes since there are no changes which are visible to anonymous users.
To make authenticated requests you need to include the "/a" prefix as explained at:
https://gerrit-review.googlesource.com/Documentation/rest-api.html#authentication

Guy Levkowitz

unread,
Feb 3, 2022, 5:20:13 AM2/3/22
to Repo and Gerrit Discussion
thanks adding the "a/"   - now it works

Many thanks

Guy


ב-יום חמישי, 3 בפברואר 2022 בשעה 12:00:36 UTC+2, ‪Edwin Kempin‬‏ כתב/ה:

Guy Levkowitz

unread,
Feb 3, 2022, 7:17:50 AM2/3/22
to Repo and Gerrit Discussion
when i run the API for : 'GET /changes/{change-id}/revisions/{revision-id}/files/{file-id}/diff'

I get  :
Multiple changes found for Ie2aaacd47e96590655941207136e8bdfba10dcad  

what does it means ? 

ב-יום חמישי, 3 בפברואר 2022 בשעה 12:20:13 UTC+2, ‪Guy Levkowitz‬‏ כתב/ה:

Edwin Kempin

unread,
Feb 3, 2022, 7:43:22 AM2/3/22
to Guy Levkowitz, Repo and Gerrit Discussion
On Thu, Feb 3, 2022 at 1:17 PM Guy Levkowitz <sil...@gmail.com> wrote:
when i run the API for : 'GET /changes/{change-id}/revisions/{revision-id}/files/{file-id}/diff'

I get  :
Multiple changes found for Ie2aaacd47e96590655941207136e8bdfba10dcad  

what does it means ? 
It means that the change has been cherry-picked to other branches. So you get the original change and the changes for all the cherry-picks of that change.
 

Nasser Grainawi

unread,
Feb 3, 2022, 10:29:13 AM2/3/22
to Edwin Kempin, Guy Levkowitz, Repo and Gerrit Discussion

On Feb 3, 2022, at 5:42 AM, 'Edwin Kempin' via Repo and Gerrit Discussion <repo-d...@googlegroups.com> wrote:



On Thu, Feb 3, 2022 at 1:17 PM Guy Levkowitz <sil...@gmail.com> wrote:
when i run the API for : 'GET /changes/{change-id}/revisions/{revision-id}/files/{file-id}/diff'

I get  :
Multiple changes found for Ie2aaacd47e96590655941207136e8bdfba10dcad  

what does it means ? 
It means that the change has been cherry-picked to other branches. So you get the original change and the changes for all the cherry-picks of that change.

To add to Edwin’s point, if you check [1], it notes a valid value for {change-id} is ' a Change-Id if it uniquely identifies one change ("I8473b95934b5732ac55d26311a706c9c2bde9940”)'

Other options (also detailed in [1]) are using a change # (not Id) as the {change-id} in your request or combining the Change Id with a project and branch.


Reply all
Reply to author
Forward
0 new messages