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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.