I am trying to access the commits of a PR using the following, but I keep getting a 403 error, forbidden url.
https://confluence.atlassian.com/bitbucket/pullrequests-resource-423626332.html?focusedCommentId=734071465#pullrequestsResource-GETthecommitsforapullrequest
Hi David,
What form of authentication are you using to make the API call? Is it username+password? Or username+app-password? Or OAuth?
In case you're using an app password or OAuth, it is possible that the app password or OAuth consumer doesn't have permissions for pull requests. There are separate permissions for pull requests when creating either an app password or an OAuth consumer.
You can check and change permissions for an OAuth consumer, but this is not possible for an app password. In case an app password doesn't have the necessary permissions, you can create a new one.
Is there any additional output from this API call, other than the 403 error code? Also, do you get the same error if you use another Bitbucket API endpoint, e.g. /2.0/repositories/{workspace}/{repo_slug}/src, with the same credentials?
Kind regards,Theodora
Hi Theodora,
I am using an app password with maximum privileges. I was able to use the app password for other endpoints, not sure why I'm getting this error for the commits portion of PRs. I am able to get info on PRs, excluding commits,
Thank you for your attention and input!
Not a problem, I'm happy to help! I have checked our logs for pull requests API calls made by the Bitbucket user that has the same email as your community account, using an app-password and with status 403 for the last week, but my search doesn't show any results.
Could you please let me know the following:
1. Are you using for the authentication the Bitbucket account with the same email as your community account?
2. Can you consistently reproduce this, or is it an intermittent issue?
3. If this error occurs every time you use this endpoint, would it be possible for you to make a new API call with this endpoint when you have the chance, and let me know the date and time you made the call in UTC (you can use this to convert the time in UTC: https://savvytime.com/converter/utc), so I can check our logs again?
Thank you for your instructions!
1) Yes, I am using the same email account. However, for app auth I use my username instead of an email address - using an email address yields a 401 error. Using the username for this account successfully allows me to auth and retrieve PRs, except for the endpoint in question that is causing 403 error.
2) Yes, it is consistent.
3) I ran it just now. Sept 10, 2021 6:23 PM UTC. requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://api.bitbucket.org/2.0/repositories/<owner>/<repo slug>/pullrequests/38/commits/
- The <owner> is not my personal account, it is a work account to which I have access - for which I am able to access other end points.
It looks like you're new here. Sign in or register to get started.