azure - 如何使用 Azure DevOps Rest API 创建多个文件夹

标签 azure azure-devops azure-pipelines azure-devops-rest-api

我正在使用 Azure DevOps Rest api 在版本中创建文件夹。 不确定,如何在同一路径中创建多个文件夹、子文件夹?

代码:

'

Param( 
[string]$organisation = "org", 
[string]$project = "testdatafactory", 
[string]$keepForever = "true", 
[string]$user = "id", 
[string]$token = "token",
[string]$path= "\\") 

$headers = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($token)")) }

$uri = "https://vsrm.dev.azure.com/$organisation/$project/_apis/release/folders/$path ?api-version=6.0-preview"


Write-Host "Uri :" $uri

$params = 
@"
{
    "createdBy": "id",
    "createdOn": "",
   "description": "test",
   "lastChangedBy": "",
   "lastChangedDate": "",
   "path": "test1"
    }
"@


$result = Invoke-RestMethod -Uri $uri -Method POST -Body $params -Headers $headers -ContentType "application/json" -Verbose -Debug

'

最佳答案

how can I create multiple folders, subfolders in same path?

恐怕没有这样的现成方法可以在同一路径中创建多个文件夹、子文件夹。

因为 Folders - Create 没有这样的 Batch REST API .

作为解决方法,我们可以多次运行 REST API 来创建多个文件夹、子文件夹。

我们可以使用 REST API:

POST https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/folders?api-version=6.0-preview.2

然后在请求正文中指定完整路径:

{
    "path": "\\Master\\test5",
    "createdBy": "id"
}

测试结果:

enter image description here

enter image description here

如果我们想在同一路径中创建子文件夹,我们只需指定路径即可:"path": "\\Master\\test5\\subfolder1":

enter image description here

关于azure - 如何使用 Azure DevOps Rest API 创建多个文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67670649/

相关文章:

Azure CLI - 硬链接(hard link)失败

javascript - 具有构建时变量的 JavaScript 应用程序管道的正确流程是什么?

azure - 尝试克隆 Azure 管道但出现 "references service connection ... not found"错误

sql-server-2008 - SQL Azure 作为链接服务器 -> 获取插入行的标识

azure - 在 MS Azure 上部署 Acumatica ERP

r - 在 Azure ML Studio 中转置和添加 R 中的列

azure-devops - 未评估 Azure Pipelines 合并

azure - 存储帐户问题?

node.js - VSTS/TFS Build 仅在提交和推送 Git 标记时运行 NPM 任务

angular - 如何为 Angular 应用程序设置 Azure Pipeline