I ran into an impasse trying to automate the creation of new git repositories using powershell.
As I understand one creates new repos using the POST Method on the url
/rest/api/1.0/projects/$ProjectKey/repos
https://developer.atlassian.com/static/rest/stash/3.0.1/stash-rest.html#idp1178320
Because you have to be admin to modify stuff I add an authorization header field to the webrequest.
$ByteArr = [System.Text.Encoding]::UTF8.GetBytes('admin:pwd')
$Base64Creds = [Convert]::ToBase64String($ByteArr)
$ProjectKey = 'SBOX'
$CreateRepoUri = "$BaseUri/rest/api/1.0/projects/$ProjectKey/repos/"
Invoke-RestMethod -Method Post `
-Headers @{ Authorization="Basic $Base64Creds" } `
-Uri $CreateRepoUri `
-ContentType 'application/json' `
-Body @{ slug='test'; name='RestCreatedRepo';}
But when executing I get an Internal Server Error (500). No more details or InnerExceptions on why exactly.
Retrieving a list of repositories with GET worked so authentication works (at least for the Get requests)
According to this, it should be a correct statement:
- https://answers.atlassian.com/questions/127261/create-project-using-rest
- powershell http post REST API basic authentication
What exactly is this slug or scmId (Anybody heard of it)?
It would be greate if one of you geniuses could point me in the right direction as I just gotten into using webservises.
Thanks, Michael