Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Retrieving comments from Bitbucket server via REST API

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

2 votes
Answer accepted
Felix Atlassian Team 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 

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

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.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Calling any interview participants for Bitbucket Data Center

Hi everyone,  We are looking to learn more about development teams’ workflows and pain points, especially around DevOps, integrations, administration, scale, security, and the related challeng...

499 views 6 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you