本文介绍了如何使用Azure DevOps睡觉API创建多个文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Azure DevOps睡觉API,在Release中创建文件夹。不确定,如何在同一路径中创建多个文件夹或子文件夹?
编码:
‘
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
‘
推荐答案
恐怕没有这种开箱即用的方法来在同一路径中创建多个文件夹或子文件夹。
因为Folders - Create没有这样的批睡觉接口
作为解决方法,我们可以多次运行睡觉API来创建多个文件夹和子文件夹。
我们可以使用睡觉接口:
POST https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/folders?api-version=6.0-preview.2
然后在请求正文中指定完整路径:
{
"path": "\Master\test5",
"createdBy": "id"
}
测试结果:
如果我们想在同一路径中创建子文件夹,只需指定如下路径:"path": "\Master\test5\subfolder1"
:
这篇关于如何使用Azure DevOps睡觉API创建多个文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!