2

I am trying to create a bitbucket repository through git bash and I am suing Curl command as below:

$ curl -k -X POST -v -u username:xxxxx -H "Content-Type: application/json" \
  https://bitbucket.org.local/projects/proj1/repos/repotest \
  -d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks" }'

Upon running this command, I am getting invalid credential error and the output looks like below: enter image description here

My credentials are correct but I am unable to create the repository. Any help?!!

2 Answers 2

3

You can try using bitbucket-cli.

First, install it using pip

pip install bitbucket-cli

Then create a repo using

bitbucket create --private --protocol ssh --scm git YOUR_REPO_NAME

Note that this creates a private git repo, you can use --public for public access and --scm hg if you use Mercurial. Username argument can be added via --username YOUR_USER_NAME.

Sign up to request clarification or add additional context in comments.

1 Comment

Do I need to install python to install pip?
0

Although pcampana's answer is correct and you could use python and pip, I was checking what could be wrong with the curl command. And I guess you are missing the rest path in the url and the name of the repository should be in the post data. (https://docs.atlassian.com/bitbucket-server/rest/6.3.1/bitbucket-rest.html#idp152)

I guess, the missing rest/api/1.0 in the url makes the server think that you want to reach a "normal" webpage for which Basic Authentication seems to not be possible.

So try:

curl -k -X POST -v \
    -u username:xxxxx \
    -H "Content-Type: application/json" \
    https://bitbucket.org.local/rest/api/1.0/projects/proj1/repos \
    -d '{"name": "repotest", "scm": "git", "is_private": "true", "fork_policy": "no_public_forks" }'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.