Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Getting 500 error on api branch permissions

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

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
Community showcase
Published in Bitbucket

Calling any interview participants for Bitbucket Data Center

Hi everyone,  We are looking to learn more about development teams’ workflows and pain points, especially around DevOps, integrations, administration, scale, security, and the related challeng...

485 views 5 4
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you