Create a repository with Bitbucket 2.0 REST api and node.js Edited

I am trying to create a repository from a command line app that I am writing. I am using node.js to send a post request to the Bitbucket 2.0 api but even though I am successful in creating the repo, it doesn't seem to honour the settings I create the repo with (e.g. is_private = true, has_wiki = true, language = PHP). I am not sure what I am doing wrong. My guess is it's the way I am formatting the body? Below is the code that I am using.

Anyone able to help? Thanks in advance!


var dataString = '{"scm": "git", "has_wiki": true, "is_private": true}';

 url: '' + username + '/' + _.kebabCase(answers.reponame),
method: 'POST',
headers: {'Authorization': 'Bearer ' + prefs.ginit.token},
body: dataString
}, function (err, res) {

 if (err) {
 reject(new Error('Couldn\'t create remote repo.'));

 let json = JSON.parse(res.body);

 if(res.statusCode == 400) {
 reject(new Error(json.error.message));

 if (res.statusCode == 200) {
 console.log('\n' + + ' created sucessfully.'));
console.log('You can view it here: ' + json.links.html.href + '\n'));





0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Aug 21, 2018 in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

1,264 views 8 11
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you