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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

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
4,459,905
Community Members
 
Community Events
176
Community Groups

How to create private repository via API 2.0?

Edited

Trying to create private repo using `curl`:

curl -X POST -H "Authorization: Bearer $TEST_TOKEN" https://api.bitbucket.org/2.0/repositories/nosuchip/__abcde -d '{"scm": "git", "is_private": "true", "private": "true, "public": "false", "is_public": "false" }'

As you see I tried a lot of different keys that COULD specify that repo should be private (Bitbucket API documentation is very confusing and misleading). It doesn't works.

I tried also specify these params one by one. Also I rplaced stringified versions `true` and `false` with boolean - nothing works.

Also I tried to create repo and then call PUT request to make it private  - PUT constantly returns "you already have such repository for this owner". Documentation for PUT is missing.

1 answer

Not sure if after few years this is still an issue. I did not find any clear doc, so here you go.

curl --location --request PUT 'https://api.bitbucket.org/2.0/repositories/<WORKSPACE_NAME>/<REPO_NAME>?access_token=<ACCESS_TOKEN>' \
--header 'Authorization: Basic <CLIENT_LOGIN_CREDENTIAL>' \
--header 'Content-Type: application/json' \
--data-raw '{
"is_private": false
}'

The above works.

 

WORKSPACE - is your workspace name

REPO_NAME - is your repository name

ACCESS_TOKEN - is generated by you to access Bitbucket via API. How to do that can be found here and here

CLIENT_LOGIN_CREDENTIAL - is generated by you to access Bitbucket via API. How to do that can be found here 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events