You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I'm trying to hit the following curl:
curl --location --request POST 'https://api.bitbucket.org/2.0/repositories/<workspace>/<repo>/pullrequests/1493/merge' \
--header 'Authorization: Bearer <access_token>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
I have created the access_token from Repository settings > Access tokens for this repo, on Bitbucket Cloud website. All the permissions are checked except Delete repo.
I'm getting the following error response:
Hi @Dhiraj Sittu and welcome to the community!
If the screenshot you shared is from the PR's destination branch, then the reason you are getting this error message is that merge of PRs is restricted only to certain users.
Repository access tokens are not associated with the user that generated them or with any other user. They also cannot be added to a branch restriction, so you won't be able to merge this PR with a Repository access token (RAT) as long as this branch restriction exists.
Merging a PR via API with a RAT is possible as long as PR merging is not restricted to certain users and everyone is allowed to merge.
If you would like to keep the branch restriction for PR merging, then the only way to merge the PR with an API call is by using the authentication details of a user who has permission to merge the PR:
curl -u BB_Username:App_Password -X POST 'https://api.bitbucket.org/2.0/repositories/<workspace-id>/<repo>/pullrequests/<pr_id>/merge'
BB_Username is the username of a Bitbucket Cloud user who has permission to merge PRs to the destination branch
App_Password is an app password for that user's account, that has Pull requests: Write permissions
We have a feature request for allowing admins to add a Repository access token to branch restrictions:
I would suggest adding your vote (by selecting the Vote for this issue link) and commenting on the feature request to give it more weight and further express your interest. You can also add yourself as a watcher (by selecting the Start watching this issue link) if you'd like to get notified via email on updates. Implementation of new features is done as per our policy here and any updates will be posted in the feature request.
Please feel free to let me know if you have any questions.
Hello Dhiraj, Welcome to the community!
I hope I can help: The request authorization header can be
If you try to send the same curl request with `curl -u "<username:accessToken>" .....` you should get the Auth header for free.
Good luck and let me know how you go!