You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.