Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Getting 500 error on api branch permissions

dylanthurston
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!
January 15, 2020

I'm not sure what is going on but i'm trying to set the permissions on a branch via the api and after fixing a lot to get my request json correct (it would be nice if the api docs had an actual example sample.) I'm just getting a 500 error. If i add a branch permission and use the get request i use the example return as value for the post (after i remove the permissions so that the permissions are completely empty). "Something went wrong" is not very helpful. Below is the json i'm sending

 

{
"kind": "push",
"type": "branchrestriction",
"branch_match_kind": "glob",
"pattern":"master",
"groups":[
{
"name": "Administrators",
"account_privilege": "admin",
"full_slug": "morindadev:administrators",
"owner":{
"username":"morindadev",
"type": "team",
"display_name": "Morinda Dev Team"
},
"type": "group",
"slug":"administrators"
}
]
}

 

This is with bitbucket cloud. I know that my oauth is working because i can do other api calls properly. I also know that my json should be good because after a lot i was finally able to get past all of the checks for missing values etc. now i'm just stuck at a 500 error and i have no idea where to go.

1 answer

0 votes
Daniil Penkin
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 15, 2020

Hello @dylanthurston,

Thanks for reaching out and welcome to the Community!

500 isn't good, we'll fix that – thanks for reporting. The reason for it seems to be that you didn't specify the content type properly, so it wasn't parsed as JSON. Adding Content-Type: application/json header should fix that.

Also, you don't need half of the attributes in the JSON you posted, here's an example payload that works for me:

curl -u dpenkin:app_password \
-H "Content-Type: application/json" \
https://api.bitbucket.org/2.0/repositories/dpenkin/test-repo/branch-restrictions \
-d '
{
"kind": "push",
"branch_match_kind": "glob",
"pattern": "test_pattern",
"groups": [
{
"owner": {
"username": "dpenkin"
},
"slug": "test-group"
}
]
}'

I agree, our API docs are suboptimal, this is on our radar.

Hope this helps. Let me know if you have any questions.

Cheers,
Daniil

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events