Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Deleting comment on pull-request fails

BRIAN CARLSON July 30, 2022

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": #### .....}}
If I iterate over the values and filter on objects containing "comment" I can parse the following info.
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,
            permittedOperations:[editable:true, transitionable:true, deletable:true]]
According to everything I've read.  I should be able to use the id=166564 to access the comment with the goal of ultimately deleting it.  If I put the url in my brower I can see the comment.
 "text":"Meaninful results of Jenkins build",
FYI I'm making (and trying to delete) the comment from Jenkins with the same bitbucket token.  And I'm going to the link for the above results 
However, when I try to delete the comment (projectKey, repositorySlug, and pullRequestId are replaced with the actual values):
curlCmd = "curl -s --insecure  -X DELETE -H 'Authorization: REMOVED TOKEN INFO' -H 'X-Atlassian-Token: no-check' https:///rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/16564"
{"errors":[{"context":null,"message":"You are attempting to modify a comment based on out-of-date information.", "exceptionName":"com.atlassian.bitbucket.comment.CommentOutOfDateException","currentVersion":0,"expectedVersion":-1}]}
adding:  comments/16564?0 yields the same result
adding:  comments/16564?-1 yields the same result
adding:  comments/16564/?-1 yields the same result
Any ideas what the issue might be?


0 answers

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events