The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I've read the documentation, and I've formatted my request body just like in the example with 1 addition:
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add('Authorization' , "$apiKey")
$headers.Add('accept', 'application/json')
$body=@"
{
"scm": "git",
"project": {
"key": "$MYKEY",
},
"is_private":$true
}
"@
try {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-RestMethod -Method PUT -Headers $headers -Body $body -Uri https://api.bitbucket.org/2.0/repositories/$workspace/$repoName -Verbose -UseBasicParsing
} catch {
echo "Something occured"
echo $_.Exception
echo $_
}
No matter what I put in the body, regardless of whether or not it's valid JSON, I always get a 200 response, the project KEY is wrong (defaults to oldest project in account), and it's not marked as a private repo.
How am I supposed to format this request so that it works in powershell?
Hey @ithryeandeus
G'Day!
Have you tried adding the key manually for example as below:
{ "scm": "git", "project": { "key": "TST" }
Let me know if the scripts works and if it's still returning an error please share with us the full error.
Additionally, if you wish to make your repositories private when created add the following additional parameter which should make it private:
{ "scm": "git", "is_private": true, "project": { "key": "MARS" }
Also, do check our newly update API page for more information on recent changes at:
I would also want to share the full curl commands so you have an idea of how the JSON data works in Bitbucket API:
curl -X POST -u "$BITBUCKET_USERNAME:$BITBUCKET_APPPASSWORD" "https://api.bitbucket.org/2.0/repositories/<Workspacename>/<Repositoriesname>" -H "Content-Type: application/json" -d '{"scm": "git", "is_private": true, "project": {"key": "TST"}}'
I hope this helps.
Cheers,
Syahrul
Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.