Reputation: 55
I am using Azure DevOps rest api , to create folder in Releases. Not sure, how can I create multiple folders, subfolders in same path?
code :
'
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
'
Upvotes: 1
Views: 952
Reputation: 76760
how can I create multiple folders, subfolders in same path?
I am afraid there is no such out of box way to create multiple folders, subfolders in same path.
That because there is no such Batch REST API for the Folders - Create.
As workaround, we could run the REST API multiple times to create the multiple folders, subfolders.
We could use the REST API:
POST https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/folders?api-version=6.0-preview.2
Then specify the full path in the request body:
{
"path": "\\Master\\test5",
"createdBy": "id"
}
The test result:
And if we want to create the subfolders in the same path, we could just specify the path like: "path": "\\Master\\test5\\subfolder1"
:
Upvotes: 1