Forums

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

Setting Bitbucket branch permissions - force and delete via API

A_ Nygren
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!
May 8, 2018

Screen Shot 2018-05-08 at 2.01.44 PM.pngI want to make an API call to do the above, in order to eliminate this currently manual step in the setup process.  

I have malformed JSON when making the post call to the branch-restrictions API endpoint.

What should the desired JSON look like?

1 answer

0 votes
A_ Nygren
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!
May 4, 2020

Almost exactly two years later to the day I have come back around to answer my own question.

Two Requests must be sent.

One for the delete...

curl -u ${BITBUCKET_USERNAME}:${BITBUCKET_PASSWORD} -X POST -H "Content-Type: application/json" -d '{
"kind": "delete",
"pattern": "master",
"branch_match_kind": "glob",
"type": "branchrestriction"
}' https://api.bitbucket.org/2.0/repositories/${BITBUCKET_WORKSPACE}/${BITBUCKET_REPO_SLUG}/branch-restrictions

 One for the force...

curl -u ${BITBUCKET_USERNAME}:${BITBUCKET_PASSWORD} -X POST -H "Content-Type: application/json" -d '{
"kind": "force",
"pattern": "master",
"branch_match_kind": "glob",
"type": "branchrestriction"
}' https://api.bitbucket.org/2.0/repositories/${BITBUCKET_WORKSPACE}/${BITBUCKET_REPO_SLUG}/branch-restrictions

 https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D/branch-restrictions

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events