Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Bitbucket REST API Error "Something went wrong" when deleting a branch

lior.regev
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 12, 2024

Hello,

I am trying to delete a branch via REST API using:
`https://api.bitbucket.org/2.0/repositories/ws/repo/refs/branches/my/branch/name` and I'm getting a 500 response with "Something went wrong".

The error ID is `394ff3fdfaea443ab72a823c4a481545`

Please advise

1 answer

0 votes
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 13, 2024

G'day, @lior.regev 

Welcome to the community!

You don't have permission to delete the branch based on the error code you shared. This could be because you don't have permission or the branch is protected by branch permission.

I suggest checking if you have admin access to the repository first, and if yes, check your branch permission to see if you can delete the branch.

Regards,
Syahrul

lior.regev
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 16, 2024
  1. According to the docs it requires `repository:write` scopes to delete a branch.
  2. I tried with a repo token having `repository:write` + `repository:admin` + `repository:delete` scopes and still get the same error. (ID `3e2daeaa90ff4751be73b4932de42fb7`
  3. At the very least, in a missing permissions error I would expect 401/403 errors, not 500.

Am I using repository tokens wrong?

Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 17, 2024

Hey @lior.regev 

Thanks for the update.

Unfortunately, using repository access tokens does not grant deletion permissions on the API endpoint. To perform this action, you must utilize either an App Password or oAuth. We are currently tracking this feature request; please follow the link below to Vote and Watch the issue:

https://jira.atlassian.com/browse/BCLOUD-22565

Regards,
Syahrul

Like Sabine Mayer likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events