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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,466,062
Community Members
 
Community Events
176
Community Groups

Deleting comment on pull-request fails

Edited

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:

https://community.atlassian.com/t5/Answers-Developer-Questions/Reading-pull-request-comments-via-REST-API-fails/qaq-p/523952 

{"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,
            author:[REMOVED],
            createdDate:1659127730708,
            updatedDate:1659127730708,
            comments:[],
            tasks:[],
            severity:NORMAL,
            state:OPEN,
            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.
/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/16564
{"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}}
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?
Thanks!

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events