我在尝试使用 powershell 自动创建新的 git 存储库时遇到了僵局。
据我了解,一个人使用 url 上的 POST 方法创建新的存储库
/rest/api/1.0/projects/$ProjectKey/repos
https://developer.atlassian.com/static/rest/stash/3.0.1/stash-rest.html#idp1178320
因为您必须是管理员才能修改内容,所以我在 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';}
但是在执行时我得到一个内部服务器错误(500)。没有更多详细信息或 InnerExceptions 确切原因。
使用 GET 检索存储库列表有效,因此身份验证有效(至少对于 Get 请求)
据此,应该是正确的说法:
- https://answers.atlassian.com/questions/127261/create-project-using-rest
- powershell http post REST API 基本身份验证
这个 slug 或 scmId 到底是什么(有人听说过)?
如果你们中的一位天才能在我刚开始使用网络服务时为我指出正确的方向,那就太好了。
谢谢,迈克尔