I am using a Jenkins groovy script using Curl commands to interact with Stash/Bitbucket.
I can successfully grab all the activity data as a JSON object using the /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/activities
as recommended here:
{"size":25, "limit":25, "isLastPage":false, "values": [{"id":185562, LOTS OF INFO},{"id": #### .....}}
comment_obj_keys = [id, createdDate, user, action, commentAction, comment]
comment_obj_keys.getClass() = class java.util.LinkedHashSet
if comment_obj_keys.contains("comment")
id = 185562
createDate = null
user = [REMOVED]
action = COMMENTED
commentAction = ADDED
comment = [ properties:[repositoryId:1794],
id:16564, version:0,
text:Meaninful results of Jenkins build,
author:[REMOVED],
createdDate:1659127730708,
updatedDate:1659127730708,
comments:[],
tasks:[],
severity:NORMAL,
state:OPEN,
permittedOperations:[editable:true, transitionable:true, deletable:true]]
{"properties":{"repositoryId":1794},
"id":16564,
"version":0,
"text":"Meaninful results of Jenkins build",
"author":REMOVED,
"createdDate":1659071192164,
"updatedDate":1659071192164,
"comments":[],
"tasks":[],
"severity":"NORMAL",
"state":"OPEN",
"permittedOperations":{"editable":false,
"transitionable":true,
"deletable":false}}
For anyone else looking for the answer for this.
You will need to add "?version=x" to your URL.
So in your case:
https:///rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/16564?version=0
(Isn't shown in documentations.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.