[英]Get file from Azure DevOps Repo Using REST API in Powershell Script
I have an Azure repo where I'm trying to get my appsettings.json file from the repo from their GET ITEM rest call here: https://docs.microsoft.com/en-us/rest/api/azure/devops/ git/items/get?view=azure-devops-rest-5.0
在 DevOps UI 上,如果我导航到我的文件,url 类似于:_git/MYREPO?path=%2FSOMETHING%2FWeb%2Fappsettings.json&version=GBdevelop
在 '' 指定的版本的存储库 'MYREPO' 中找不到 appsettings.json'
我的 powershell 是这样的:
$appSettingsPath = "%2FSOMETHING%2FWeb%2Fappsettings.json"
$branchVersion = "develop"
$repoQueryURL = "https://" + $account +
"/DefaultCollection/" + $projectName + "/_apis/git/repositories/MYID/" +
"items?path=path=$appSettingsPath&versionDescriptor.version=$branchVersion&api-version=5.0"
Write-Host $repoQueryURL
$repoListResponse = Invoke-RestMethod -Uri $repoQueryURL -Method Get -ContentType application/json -Headers $header
无论我做什么,似乎都找不到这个明确可用的文件(并且可以在 DevOps Repo UI 中导航到)。
我哪里出错了有什么帮助吗?
检查您的 URL。 它有双路径 - path=path=
。 更新到
$repoQueryURL = "https://" + $account +
"/DefaultCollection/" + $projectName + "/_apis/git/repositories/MYID/" +
"items?path=$appSettingsPath&versionDescriptor.version=$branchVersion&api-version=5.0"
你可以试试scopePath=/SOMETHING/Web/appsettings.json
看看结果如何。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.