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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

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

2 answers

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

It looks like the v2 API doesn't work to set the branch at all:


curl ... -H 'Accept: application/json' -H 'Content-Type: application/json' -X PUT -d '{"mainbranch": { "name": "somexistingbranch", "type": "branch" } }'


returns a 200 OK but doesn't change the default branch.


This looks like a bug?

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events