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,502,477
Community Members
 
Community Events
180
Community Groups

Reading pull request comments via REST API fails

Hi!

Calling the /comments endpoint of the pull-request REST API returns an error response: "The path query parameter is required when retrieving comments."

I tried adding a "path" query parameter, but can't figure out it's content. My intention is to fetch all the comments for a PR, but I'm especially interested in the general comments which aren't specifically targeted at any file. The REST API description doesn't even mention the path query parameter.

The curl command line I've tried is:

curl --user xyz "https://pgit1.ray.fi/rest/api/1.0/projects/XYZ/repos/ABC/pull-requests/51/comments"

And with path (this gives a proper response, but without any comment payload):

curl --user xyz "https://pgit1.ray.fi/rest/api/1.0/projects/XYZ/repos/ABC/pull-requests/51/comments?path=/"

 

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted

Hi Jaakko,

I tested the REST API function locally and in fact you can't use the "comments" function without the "path" parameter, thus it looks it can't be used to retrieve general comments. I think it would be nice to have it as optional, so though I can't provide a resolution for you to get general comments using it I've created a suggestion to change this, which you can check at https://jira.atlassian.com/browse/STASH-7643. Please feel free to add any comments to it, as well as voting for it and adding yourself as a watcher to track its progress. You may refer to Atlassian's Policy for the implementation and changes on features.

As per the "path" parameter itself, you should be able to retrieve comments for specific files within your pull request by setting all the path to them, but without the first slash in front of the name, e.g. if I have a file named file2 which is under the dir1 directory located at the root of my repository the call to the function to retrieve comments within file2 would be as follows:

http://localhost:7990/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments?path=dir1/file2

For general comments, in the meantime, I'd recommend using the function /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/activities, which will return all the activity for a pull request, including general comments.

Regards,

Gustavo Refosco

Thank you! While it kind of feels like a work-a-round, the activities API fulfilled our needs.

What is the path?

is it "/"

or what should i specify there?

We have a code review coverage checker script which checks all commits and whether they're review'd or not (based on approvers in PR's and commit authors). The script also checks the PR comments for additional approvals added *after* the PR has been merged. Such additional approvals are required if it's later discovered the PR has been approved by a single person who also authored commits to the PR. The PR comment contains a marker text and the hash of a commit, which basically means 'I approve all commits in this PR up until this commit'. We do the coverage analysis for PCI (Payment Cards Industry) compliance.

0 votes
Adam Atlassian Team Jul 21, 2015

Jaakko, can I ask why you want this? What are you planning to do with the comments? I'm trying to gauge the usefulness of an endpoint like this in general and make sure we get the API right for it if we do implement it. Cheers!.

Yes, there is great need for this. I can think of plenty of uses for fetching comments from a Pull Request. 

For me, I need to fetch comments so I can present them to our clients during code reviews of their SDK submissions. They can't see our internal BitBucket server, we copy over the approvals and comments to a JIRA ticket they have access to. 

I am having to use the activities endpoint as well, which is chaos, and would love a dedicated endpoint to return the latest version all line item comments, file level comments and overview level comments. 

In addition, the information out there regarding the "comments" endpoint is incorrect, nor do the examples provided in the community work. I've passed in the exact path (as returned by the activities endpoint) to the comments endpoint and did not see any success. Not to mention, I have to hit the activities endpoint to get the variable values for the comments endpoint (?? blunder). 

Anyways, yeah there's a huge need for this. 

I've made an application for my company tracking stats across Bitbucket (and Jira) and I would have loved to have this feature.

TAGS
AUG Leaders

Atlassian Community Events