API v2 how to get the list of pull requests that a commit is part of?
Asked by Esteban Vargas:

I saw [this question](https://community.atlassian.com/t5/Bitbucket-questions/How-to-get-list-of-pull-requests-a-commit-is-part-of/qaq-p/849670) for the API v1, but not for v2

I am trying to make [this very basic http request](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-pullrequests-selected-user-get) but I get a "resource not found error". The API docs say that I must install the Pull Request Commit Links app, but I see no such app on the marketplace


Answers:
author: Theodora Boudale
body: Hi [@Esteban Vargas](/t5/user/viewprofilepage/user-id/5109096),

You can use the following endpoint:

* <https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-commit-commit-pullrequests-get>

<br />

Please follow the steps below in order to install the Pull Request Commit Links app first:

1. Open the repository in Bitbucket Cloud website  

2. Select the **Commits** page of the repo, and then select the commit hash of a commit that is part of a PR in that repo  

3. While viewing the commit details, look at the info on right side of the page. You will see there a link **Pull requests,** like in the screenshot below:  

   ![Screenshot 2022-12-30 at 15.05.11.png](https://community.atlassian.com/t5/image/serverpage/image-id/232542i9593A6EDEE31940F/image-size/large?v=v2&px=999 "Screenshot 2022-12-30 at 15.05.11.png")  

4. Select that link and the Pull Request Commit Links app will be installed.

You only need to do this once for a specific workspace, and then please try running the API call again.

In case you still have issues, could you please provide the API call you are running and the full output? Make sure to sanitize any private/sensitive data in the call prior to sharing it here.

Kind regards,  
Theodora

comments: author: Esteban Vargas
body: Thanks! This works.

Following the steps to install Pull Request Commit Links you outlined solved this issue for us! I think that should be included on the docs

And second, the docs also need a small update: The docs say this endpoint doesn't need a Bearer token, but it does


author: Theodora Boudale
body: Hi Esteban,

It's good to hear that the issue has been solved!

Would you mind telling me where exactly you saw that this endpoint doesn't need authentication? Accessing any private content always requires authentication.

The instructions on how to install the app are included in the doc, although not in as much detail as my previous post. I will reach out to the team that maintains this doc to improve it.

Kind regards,  
Theodora


author: edalel
body: I found in that same page, in the ["List pull requests that contain a commit" part](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-commit-commit-pullrequests-get) that:  
Pull Request Commit Links app must be installed first before using this API; installation automatically occurs when 'Go to pull request' is clicked from the web interface for a commit's details.

comments: author: Esteban Vargas
body: From what I understand this is now a built-in feature on Bitbucket Cloud, and that's why there's no such app on the Marketplace anymore.


author: Akshara Anilkumar
body: I am unable to get the entire response after using the list pull request that contain a commit end point. Is there a way to resolve this issue?


author: Theodora Boudale
body: Hi [@Akshara Anilkumar](/t5/user/viewprofilepage/user-id/5304231) and welcome to the community!

Please see my response here with steps you need to follow before using this endpoint: <https://community.atlassian.com/t5/Bitbucket-questions/API-v2-how-to-get-the-list-of-pull-requests-that-a-commit-is/qaq-p/2225426#M88911>

If you are still experiencing issues, please create a new question via <https://community.atlassian.com/t5/forums/postpage/board-id/bitbucket-questions> and provide more details, like the API call you are running and the output you get (after sanitizing private data).

It's best to have a separate question if you need assistance, otherwise, an existing question can become difficult to follow if we try to troubleshoot multiple users' issues.

Kind regards,  
Theodora


Tags: bitbucket-cloud

cloud