Gerrit 2.8.5 REST API Add Comment

2,174 views
Skip to first unread message

Mike Watson

unread,
Mar 18, 2015, 11:41:04 AM3/18/15
to repo-d...@googlegroups.com
Hi,

I would like to add a comment to a change in Gerrit (2.8.5) via REST API. However, I don't see any endpoint in the REST API documentation for adding a comment.

Can anyone point me to a doc or provide info if this is possible via REST API?

thx
-mike

Mike Watson

unread,
Mar 18, 2015, 11:54:20 AM3/18/15
to repo-d...@googlegroups.com
Never mind...I found it under Create Draft in documentation.....

David Ostrovsky

unread,
Mar 18, 2015, 11:55:52 AM3/18/15
to repo-d...@googlegroups.com

Mike Watson

unread,
Mar 19, 2015, 10:29:49 AM3/19/15
to repo-d...@googlegroups.com
Thanks for the link.  I am having issues understanding what the api requires for change id in many of the rest api methods for the changes end point.

In the docs it reads "'POST /changes/{change-id}/revisions/{revision-id}/review'"

In the example it reads "POST /changes/myProject~master~I8473b95934b5732ac55d26311a706c9c2bde9940/revisions/674ac754f91e64a0efb8087e59a176484bd534d1"

My question is ..are we supposed to prepend the change id with the project and branch using the tilde?  I can't get the simple call to "get a change" to work...using the change id alone, or by prepending the project and branch to the change id.

I am using the change id that is visible in gerrit UI when you open the change.  The revision id I am using is the ID assigned to the only patch set for the change (patch set 1).

Am I not using the correct IDs?

thx
-mike

Edwin Kempin

unread,
Mar 19, 2015, 10:33:14 AM3/19/15
to Mike Watson, Repo and Gerrit Discussion
2015-03-19 15:29 GMT+01:00 Mike Watson <mike.a...@gmail.com>:
Thanks for the link.  I am having issues understanding what the api requires for change id in many of the rest api methods for the changes end point.

In the docs it reads "'POST /changes/{change-id}/revisions/{revision-id}/review'"

In the example it reads "POST /changes/myProject~master~I8473b95934b5732ac55d26311a706c9c2bde9940/revisions/674ac754f91e64a0efb8087e59a176484bd534d1"

My question is ..are we supposed to prepend the change id with the project and branch using the tilde?  I can't get the simple call to "get a change" to work...using the change id alone, or by prepending the project and branch to the change id.

I am using the change id that is visible in gerrit UI when you open the change.  The revision id I am using is the ID assigned to the only patch set for the change (patch set 1).

Am I not using the correct IDs?

thx
-mike


On Wednesday, 18 March 2015 11:55:52 UTC-4, David Ostrovsky wrote:

Am Mittwoch, 18. März 2015 16:41:04 UTC+1 schrieb Mike Watson:
Hi,

I would like to add a comment to a change in Gerrit (2.8.5) via REST API. However, I don't see any endpoint in the REST API documentation for adding a comment.

Can anyone point me to a doc or provide info if this is possible via REST API?



--
--
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.
For more options, visit https://groups.google.com/d/optout.

Mike Watson

unread,
Mar 19, 2015, 10:51:40 AM3/19/15
to repo-d...@googlegroups.com, mike.a...@gmail.com
thanks for the link...and although I had not seen that info before, I have tried using all three variations in my testing...i used the change id that you see in the emails..I used the change id that is displayed in the UI when viewing a change....and I prefixed the change id (from UI) with my project and my branch....each time I get a 404 Not Found error. Driving me crazy ...  

-m

Edwin Kempin

unread,
Mar 19, 2015, 10:56:42 AM3/19/15
to Mike Watson, Repo and Gerrit Discussion
2015-03-19 15:51 GMT+01:00 Mike Watson <mike.a...@gmail.com>:
thanks for the link...and although I had not seen that info before, I have tried using all three variations in my testing...i used the change id that you see in the emails..I used the change id that is displayed in the UI when viewing a change....and I prefixed the change id (from UI) with my project and my branch....each time I get a 404 Not Found error. Driving me crazy ...  
Make sure to inlcude the /a/ into the URL so that you are authenticated:
  https://gerrit-review.googlesource.com/Documentation/rest-api.html#authentication

Otherwise your request is anonymous and anonymous users may not have read permissions on your change which would result in 404.

Mike Watson

unread,
Mar 19, 2015, 10:56:46 AM3/19/15
to repo-d...@googlegroups.com
Hmmm...Just got get change working using the legacy change id...and also tested with change ID from UI...and it is working....this is weird....perhaps there may have been some corruption in the curl strings I was using to test it.  I was being very careful though...oh well...it is working now.  thanks!

Mike Watson

unread,
Mar 19, 2015, 10:58:51 AM3/19/15
to repo-d...@googlegroups.com, mike.a...@gmail.com
Thanks for your help Edwin!


On Thursday, 19 March 2015 10:33:14 UTC-4, Edwin Kempin wrote:
Reply all
Reply to author
Forward
0 new messages