Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Setting the default branch with REST API



I am trying to create a Jenkins Job that automate the creation of Repository in Bitbucket.

I am facing issues with switching default branch using the REST API-

When I call the API with GET- I am receiving the correct value, but when I try to use the POST for setting value, I don't get any errors, but the default branch is not set.

This is what I try to call-

curl --user <user>:<password> -H "Content-Type: application/json" --data '{ "id": "<New branch>" }' -X POST https://<host>/rest/api/1.0/projects/<Project key>/repos/<repo name>/branches/default

1 answer

1 accepted

0 votes
Answer accepted
Dave Chevell Atlassian Team Apr 12, 2020

Hey Eyal_Goren,


The short answer is that you're using the wrong HTTP verb - you should be using PUT, not POST.

More generally, in REST API semantics POST is typically used for creating new resources (e.g. the API to create a branch uses POST), whereas PUT is used for updating existing resources (e.g. in this case, where we're changing the default branch but not creating anything new).

See also

Thanks, now it worked!!

Like hosssamezzoukh likes this

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

3,713 views 10 16
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