Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How do I create a new repo via 2.0 API and powershell?

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')
"scm": "git",
"project": {
"key": "$MYKEY",

try {
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-RestMethod -Method PUT -Headers $headers -Body $body -Uri$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? 

0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Bitbucket

Share your use cases: How do you use the Bitbucket-Jira integration? How does it help your team?

Hey everyone, over the past year, we've added several new features to how you can use Bitbucket and Jira together. We'd love to know how you'll are using the integration and how it's helping your tea...

59 views 0 2
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you