Hi,
I manage to successfully create a repository using the REST API by using that kind of REST call:
curl -X POST -v -u username:password -H "Content-Type: application/json" \ https://api.bitbucket.org/2.0/repositories/teamsinspace/new-repository4 \ -d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks" }'
However, this repository is created in an arbitrary project ? How can I specify the project when creating the repository ?
I didn't find anything related to project management in the REST documentation.
Thanks
Project support in some of our APIs (like repo creation) is lagging a bit. You are not currently able to a specify which project a repo should be created into. Know that we are actively working on filling those gaps though.
Once finished, you'll be able specify the project by adding the project object to your repo payload in the same way as it is currently included in the repo object:
-d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks", "project": {"key": "MYPROJ"} }'
Thanks, even if it's not the answer I expect to hear
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Erik van Zijst Are there any improments over this in the professionnal/private/paid version of Bitbucket ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm the engineer currently working on the projects API and integrating projects into the rest of the APIs. As far as I can see, the work should be finished in 3 weeks, assuming no unexpected work derails the timeline (famous last words). Sorry for the inconvenience.
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.
Hey @Abhin Chhabra and @Erik van Zijst,
do you have any updates on this ? I saw there was some announcements on bitbucket, but didn't see if there was improvements over the REST API ?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry to jump in this conversation ...
I'd like to craete bew repo in bitbucket by using REST version 1, seems my bitbucket server does not support version 2.
So can some help me out to know correct syntex to create repo in specific project (for version 1) ??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, do you have updates about this issue? Are we able at this moment to create a repository inside an specific project using API? If yes, how should we invoke the api?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
By adding "name" parameter to post data:
-d
'{"scm": "git","is_private": "true","fork_policy":"no_public_forks","name":"NewRepo"}'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The OP is asking how to specify the project, not the name.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Guys,
Can anyone answer this question please? I'm trying to create a "Project" via API/bash script and the bit bucket API documentation is terrible. Any direction pointing to the correct API is much appreciated. I'm using bitbucket version 5.10.1
Cheers,
Carthik
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Can someone 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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey. The basic project API has now been deployed. So you can created/update/delete projects via the API. You can see the documentation for that here: https://developer.atlassian.com/bitbucket/api/2/reference/search?q=tag:projects
Support for choosing the project during repository creation was recently finished and is in our deployment pipeline. It should get deployed today.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I have tried to specify project during repository creation like this:
{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks", "project": {"key": "MYPROJ"} }
but can not get it to work. Am I not doing it correct?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you please paste the exact command you're using and the actual response you're getting?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello, I have tried the following command:
curl -X POST -v -u user:pass https://api.bitbucket.org/2.0/repositories/myteam/myrepo -H "Content-Type: application/json" -d '{"is_private": true, "language": "php", "project": {"key": "PROJ"}}'
and got the response:
* upload completely sent off: 67 out of 67 bytes < HTTP/1.1 403 FORBIDDEN * Server nginx/1.6.2 is not blacklisted < Server: nginx/1.6.2 < Vary: Authorization, Cookie < Content-Type: application/json; charset=utf-8 < Strict-Transport-Security: max-age=31536000 < Date: Wed, 03 Aug 2016 19:56:55 GMT < X-Served-By: app-111 < X-Static-Version: c4b639339c4d < ETag: "2517d8a35dee8cb8cd9e5f0c889915ba" < X-Render-Time: 0.0306060314178 < X-Accepted-OAuth-Scopes: repository:admin < Connection: keep-alive < X-Version: c4b639339c4d < X-Request-Count: 235 < X-Frame-Options: SAMEORIGIN < Content-Length: 35 < * Connection #0 to host api.bitbucket.org left intact {"error": {"message": "Forbidden"}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Luiz,
That exact payload works fine for me. So perhaps the problem is auth related. Perhaps you don't have access to create repositories on that account. Or perhaps if you're using something that allows scopes (app passwords, for example) and don't have the "repository:admin" scope.
Please let me know if any of those 2 guesses help you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Abhin, sorry to jump in, but creating repo for specific Project is not working for me either.
I am using
curl -X POST -v -u abc:abc http://abc.test.com/2.0/repositories/projectname/repositoryname -H "Content-Type: application/json" -d '{"is_private": true, "language": "php", "project": {"key": "projectkey"}}'
I get this
* upload completely sent off: 69 out of 69 bytes
< HTTP/1.1 404 Not Found
< Server: Apache-Coyote/1.1
< X-AREQUESTID: @<redacted>
< X-ASEN: SEN-5840674
< X-AUSERID: 4064
< X-AUSERNAME: <redacted>
< X-XSS-Protection: 1; mode=block
< X-Frame-Options: SAMEORIGIN
< X-Content-Type-Options: nosniff
< Set-Cookie: JSESSIONID=<redacted>; Path=/; HttpOnly
< Pragma: no-cache
< Expires: Thu, 01 Jan 1970 00:00:00 GMT
< Cache-Control: no-cache
< Cache-Control: no-store
< Content-Type: text/html;charset=UTF-8
< Content-Language: en-US
< Transfer-Encoding: chunked
< Vary: Accept-Encoding
What am i doing wrong here ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Neetu: I think your URL might be wrong. I see that you're using "projectname" after "repositories". The account/team username is supposed to go there.
Luiz: I think I might know what's going on. This might be an actual bug with BB, where it requires one to be an account admin for creating repos using the API. I fear that the authorization requirements of creating a repo via the API vs. the UI have gone out of sync. I have a bugfix PR out and it should get merged and deployed in a couple of days. The bug would be my fault and I apologize for that. In the mean time, could you please try to authenticate as an account admin?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the reply Abhin. I think this is it, the authorization requests are different via API vs UI. However, even authenticating as an admin I can only create repositories under the default PROJ project, when I try to create one on a different one I get an unathorized response. Can you look into that too? Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Luiz,
That's a bit strange. I am able to create repositories under various projects just fine. Could you please paste the curl command you used for creating a repo in another project and the actual result you got? Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
curl -X POST -v -u user:pass https://api.bitbucket.org/2.0/repositories/myteam/myrepo -H "Content-Type: application/json" -d '{"is_private": true, "language": "php", "project": {"key": "PROJ"}}'
* upload completely sent off: 66 out of 66 bytes < HTTP/1.1 401 UNAUTHORIZED * Server nginx/1.6.2 is not blacklisted < Server: nginx/1.6.2 < Vary: Cookie * Authentication problem. Ignoring this. < WWW-Authenticate: Basic realm="Bitbucket.org HTTP" < Content-Type: text/html; charset=utf-8 < Strict-Transport-Security: max-age=31536000 < Date: Wed, 03 Aug 2016 21:14:16 GMT < X-Served-By: app-112 < X-Static-Version: c4b639339c4d < ETag: "d41d8cd98f00b204e9800998ecf8427e" < X-Render-Time: 0.016921043396 < Connection: keep-alive < X-Version: c4b639339c4d < X-Request-Count: 111 < X-Frame-Options: SAMEORIGIN < Content-Length: 0
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Luiz,
Unfortunately, I'm not able to reproduce this issue locally. Can you tell me some details about the team and the project? For example, is the project public or private. I also know that you're attempting this as an admin on the team.
Also, I noticed that this is an authentication problem and not an authorization problem. Can you confirm that you are attempting this with the same set of credentials as were used to create the repo in the PROJ project?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I also understand that you feel uncomfortable sharing all the details of your request on a public forum (as you should). Feel free to contact me via email using "abhin at atlassian.com".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Abhin for the quick reply. I was not able to create it the way you suggested.I think 2.0 is for Bitbucket cloud ? We are using bitubucket server4.4
curl -X POST -v -u user:pass http://abc.com/rest/api/1.0/projects/{projectkey}/repos -H "Content-Type: application/json" -d "{\"name\": \"{reponame}\",\"scmId\": \"git\", \"forkable\": true }"\ worked for me for successful creation of Repository in project.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Neetu,
Yes, this is all for Bitbucket Cloud. The question is also tagged as "bitbucket-cloud". Bitbucket server has a different API.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Abhin,
I'm also having a hard time getting this to work. This is the code I'm using:
curl -X POST -v -u $BB_UN:$BB_PW https://api.bitbucket.org/2.0/repositories/digitaldeployment/$SITE_NAME -d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks", "project": {"key": "Tools"} }'
I'm able to create a repo, but it doesn't go to the appropriate project.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.