We have a company wide bitbucket and I have an account and have an existing project. Could someone please help me how to create a repo using REST API call. I can access bitbucket using the "bitbucket.<company_name>.com" and create a repo manually.
Thanks in advance for the help.
Hello,
Have a look at this Rest Api documentation:
Hi Alex, thank you so much for your help, I think I'm in the right direction now, I followed the link that you mentioned above and created my json and ran the curl command as mentioned below for creating a repo in a project, i got the response as :
"Repository abc/test does not exist."
and when i created the same repo manually and run the same below command it says:
"This repository URL is already taken by 'test' in 'ABC'".
and when i don't mention reponame in the url ( just https://bitbucket.<mycompany>.com/rest/api/1.0/projects/abc/repos" and it says:
"A repository name must be provided to create a repository."
Here is my command:
curl -u <username>:<password> -X POST -H "Content-Type: application/json" -d '{
"slug": "test",
"forkable": false,
"project": {
"key": "ABC"
}
}' https://bitbucket.<mycompany>.com/rest/api/1.0/projects/abc/repos/test
In the above command, 'abc' is my project, 'ABC' is my project key and 'test' is the repo that I'm trying to create.
Could you please check if I'm doing anything wrong? Thank you so much for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Alexey Matveev
Do you know to create a new repo from existing repo but of a specific branch only currently if I apply @Srini 's solution the new repo, I create has all the branch from the parent repo, do you what else we need to add in the body of request so that the new forked repo consist only the branch that I want to create from parent repo
I couldn't find that in docs.
I tried giving the id of the branch in the Json body but didn't work.
Best Regards,
Neel.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Srini,
From the create repo endpoint, it looks like the wrong URL might be called in your curl command. The endpoint you'll want to hit is:
https://bitbucket.yourcompany.com/rest/api/1.0/projects/ABC/repos
(swapping out yourcompany and ABC with the correct values)
The slug doesn't need to contain the project - just the repo name and scmId:
{
"name": "My repo",
"scmId": "git",
"forkable": true
}
Hope that helps!
Cheers,
Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bney,
The endpoint only accepts one project at a time. If you need to create multiple projects, I'd suggest using a loop in your code to iterate over the list of projects you need to create and submit a new API request for each one.
Cheers,
Daniel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.