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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Create repository to an existing project using API 2.0 on Bitbucket Cloud

I am trying to create repositories and add them to specific projects by using:

 curl -X POST -u "${bcUser}:${bcPass}" "https://api.bitbucket.org/2.0/repositories/${workspace}/${repo_lower}" \
-H "Content-Type: application/json" \
-d '{"is_private": true, "language": "php", "project": {"key": '$project'}}'

But it is not considering the parameters passed. Just checked on the documentation:

https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Bworkspace%7D/%7Brepo_slug%7D

And is_private, language and project don't seem to be part of the options specified. I am new on this, and I would like to be able to specify the privacy as well as moving the created repository to an existing project.

After creating the repository, I tried moving the repository to the existing project with the following command, but did not work either:

curl -X PUT -u "${bcUser}:${bcPass}" "https://api.bitbucket.org/2.0/workspaces/${owner}/projects/${project}" \
-d '{"repositories": "https://api.bitbucket.org/2.0/repositories/${owner}/'${repo_lower}'"}'

 

I am working on Bitbucket Cloud. Thanks in advance

1 answer

1 accepted

0 votes
Answer accepted

I'm answering myself in case somebody needs it ( I assume the URL needs to be the last one...):

curl -X POST -u "${bcUser}:${bcPass}" \
-H "Content-Type: application/json" \
-d '{ "scm": "git", "is_private": true, "project": {"key": "'${project}'"}}' \ "https://api.bitbucket.org/2.0/repositories/${owner}/${repo_lower}"

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Bitbucket

Contest: Share your custom Bitbucket Pipe and win

Announced in this blog, this holiday season we’re celebrating all things CI/CD and between now and the end of 2019 we’ll be showcasing content, use cases, feature announcements and more. One featur...

2,122 views 11 6
Join discussion

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