1

I used to do

curl -k -X POST --user john@outlook.com:doe13 "https://api.bitbucket.org/1.0/repositories" -d "name=logoApp"

and success.


now I got : error

{"type": "error", "error": {"message": "Resource removed", "detail": "This API is no longer supported.\n\nFor information about its removal, please refer to the deprecation notice at: https://developer.atlassian.com/cloud/bitbucket/deprecation-notice-v1-apis/"}}

Does anyone know a know way to do this ?

brian d foy
  • 129,424
  • 31
  • 207
  • 592
code-8
  • 54,650
  • 106
  • 352
  • 604

2 Answers2

1

There's a difference between a success from curl (OK:200) and an error from the service you're trying to use. The error, however, mentions that you're trying to use the Cloud Rest API version 1, which is deprecated effective 30 June 2018.

Read this for more information.

Bayou
  • 3,293
  • 1
  • 9
  • 22
  • Do you know what is the correct curl command for the new one ? – code-8 Oct 03 '19 at 13:01
  • I tried this also, `curl -k -X POST --user john@outlook.com:doe13 "https://api.bitbucket.org/2.0/repositories" -d "name=logoApp"` I see no error, but nothing added either. – code-8 Oct 03 '19 at 13:02
  • I don't know what you're trying to do, but [this link](https://developer.atlassian.com/bitbucket/api/2/reference/search?q=repositories) will be useful to you – Bayou Oct 03 '19 at 13:02
  • I don't have a Bit Bucket account, but you can take a look at [this](https://stackoverflow.com/questions/38347458/bitbucket-api-2-create-repository-in-a-team-project) accepted SO answer. – Bayou Oct 03 '19 at 13:09
1

I don't use Bitbucket Server (a local option), and I think that has more features for this sort of thing.

For the public Bitbucket, you can still do it but it isn't documented.

The v1.0 API has been removed, and the new v2.0 API doesn't document a POST to a /repositories. Instead, you have to hit an endpoint that includes the repo that doesn't yet exist: /repositories/workspace/repo_slug

The JSON payload needs to know the project for the repo: look in the slug for a project that already exists. Fill in the user/team and repo name in the URL. And, you can make an application password so you aren't using your account password. This app password can limit the scope of what that access can do.

 % curl -X POST --user 'user:app_pass'  \ 
    -H "Content-type: application/json" \
    -d '{"project":{"key":"PROJ"}}'     \
   "https://api.bitbucket.org/2.0/repositories/USER/REPO" 
brian d foy
  • 129,424
  • 31
  • 207
  • 592