1

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

'

1 Answer 1

1

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:

enter image description here

enter image description here

And if we want to create the subfolders in the same path, we could just specify the path like: "path": "\\Master\\test5\\subfolder1":

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.