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,556,459
Community Members
 
Community Events
184
Community Groups

Retrieving comments from Bitbucket server via REST API

Rudy Holtkamp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Dec 22, 2015

Hi,

I'm using Bitbucket server and I want to get the general comments of a pull request via the REST API. But somehow it does not work.

I've used https://bitbucket/rest/api/1.0/projects/MYPROJ/repos/myrepo/pull-requests but the response is a JSON object, with a lot of data, but the only reference to comments is: 

"properties": { "commentCount": 12,"openTaskCount": 0,"resolvedTaskCount": 0}, 

When I take a specifc pull request using: https://bitbucket/rest/api/1.0/projects/MYPROJ/repos/myrepo/pull-requests/2 then I will get another JSON object wit a lot of data, but no reference to any of the comments at all.

I only get the particulars of a comment using  https://bitbucket/rest/api/1.0/projects/MYPROJ/repos/myrepo/pull-requests/2/comments gives me an error: "The path query parameter is required when retrieving comments."

 Explicitly querying for comments with https://bitbucket/rest/api/1.0/projects/MYPROJ/repos/myrepo/pull-requests/2/comments/2916  does give me all the details of that specific comment, but I can only get the commentid by looking in the UI.

So can somebody explain how to get all general comments of a pull request?

Thanks,
Rudy

1 answer

1 accepted

3 votes
Answer accepted
Felix
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Dec 22, 2015

Hi Rudy, 

I believe the best way for you to get all the comments of a pull request is to use the activities endpoint.

You'll have to filter out anything that is not a comment, but it's going to be easier to do than grabbing comments individually for every file. 

As you discovered, the comments endpoint requires specifying a path as a query parameter, so only allows retrieving comments per file.

An example of this would be:

https://bitbucket.example.com/rest/api/1.0/projects/EXMP/repos/example/pull-requests/1/comments?path=path/to/file.java

 

I hope this helps, 

Felix Haehnel
Graduate Developer
Bitbucket Server 

Rudy Holtkamp
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jan 05, 2016

Thanks Felix, The activities endpoint will do it for me. It is way more data then I need, but better then nothing!

Like avsaditya likes this

Can we do this without specifying path to the file

Like piyush_kumar_singh likes this

how can we fetch all comments in a PR irrespective of file.

Hello @piyush_kumar_singh @Paramanand Dhur1

Unfortunately, there is no end point to get all comments in a single shot.

But you could use the mechanism suggested by Felix above.

For retrieving the changes in the PR, please use

https://docs.atlassian.com/bitbucket-server/rest/7.14.0/bitbucket-rest.html#idp323

 

Thanks and Regards

Aditya

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events