Creating branches using the Bitbucket REST API

samfulton February 15, 2016

This question is in reference to Atlassian Documentation: repository Resource

Is there a way to create a branch in a Bitbucket cloud repository using the REST API? There's a button on the Web UI to do so.. I know I can use git itself to create and push a branch, just wondering if I can do it in our build process without cloning the repo locally first. 

2 answers

1 vote
Josh Boon
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!
September 15, 2016

it's not the official API docs but I traced the web call from the frontend but this works

curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -vv -u '$USERNAME:$PASS' "https://bitbucket.org/branch/create" -s -d 'repository=$TEAMORUSER%2F$REPO&from_branch=master&branch_name=staging'

 

Ben Neill
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!
November 16, 2016

Didn't have any luck with that:

'from_branch' is not recognized as an internal or external command,
operable program or batch file.
'branch_name' is not recognized as an internal or external command,
operable program or batch file.
Josh Boon
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!
November 18, 2016

Worked for me just a few minutes ago. Can you provide the command you're using without your credentials scrubbed?

 

Ben Neill
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!
November 20, 2016

Ergh, apologies, it's working fine.

 

Must have missed a typo the other day.

0 votes
Robbie Dowie
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 10, 2016

Any answer on this?  I need to do this as well.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events