Missed Team ’24? Catch up on announcements here.

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

How do I create a repository in BitBucket using REST API calls?

Shawn Singh February 15, 2019

We have BitBucket v5.10.0.

I've created a project and granted admin access to it.

I'd like to use that account to make REST calls to create repositories.

Is this possible to? and if so does anyone know the calls (using cURL or otherwise) that need to be made?

Since I asked this question, I came across the REST API browser and using the browser I can post and see the new repo. This has allowed me to see what endpoint I need to use; however, still not quite sure how to structure my curl statement...

Running this doesn't cause an update to the project... ie. no new repo.

curl -X POST -H "application/json" --user auser:theirpassword https://git-dev.csx.com/rest/api/1.0/projects/AN/repos --data '{"name":"rnstest","scmid":"git","forkable":"true"}'

1 answer

1 accepted

1 vote
Answer accepted
Marty
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 15, 2019

Hi Shawn,

here is the method you can use - POST to /rest/api/1.0/projects/{projectKey}/repos

https://docs.atlassian.com/bitbucket-server/rest/5.10.0/bitbucket-rest.html#idm532026523120

Shawn Singh February 15, 2019

Martyn,

Thank you so much for your response. I came up with a curl command, but something still isn't quite right as I don't see the repo getting created... 

Here is my command:

curl -X POST -H "application/json" --user auser:theirpassword https://git-dev.csx.com/rest/api/1.0/projects/AN/repos --data '{"name":"rnstest","scmid":"git","forkable":"true"}'

What am I missing?

Like Marty likes this
Marty
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 15, 2019

I think you need to put the --data before the url

Shawn Singh February 15, 2019

You aren't gonna believe it... the issue is I needed to have the "Content-type:" in the header... like so:

curl -X POST -H "Content-type: application/json" --basic --user auser:theirpassword --data '{"name":"rnstest","scmid":"git","forkable":true}' https://git-dev.csx.com/rest/api/1.0/projects/AN/repos

Thank you for your help!

Like Marty likes this
Rashmi April 30, 2019

Hi Shawn,

 

Can you please confirm the curl command to create new Bitbucket project as well as repo?

My bbt repo is something like below:

 

https://abc-bbt.corp.abc.com/bitbucket

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events