0

I was trying to download the folder from a GIT based repository in Azure DevOps. I was able to download it through the below script.

$token = "PAT"

$url="https://dev.azure.com/{ORG}/{PROJECT}/_apis/git/repositories/{RepoNameORRepoID}/items?scopePath=folderpath(e.g. doc/build/html )&download=true&`$format=zip&api-version=6.0"

$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))

$response1 = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Get -ContentType application/zip -OutFile "c://repo.zip"

The above script works perfectly on the machines. The script fails when I try to run this powershell script from Azure DevOps release pipeline. I have created a release pipeline and added a powershell task to download the folder from a GIT based repository.

It fails with error Invoke-RestMethod : Unable to connect to the remote server

Please let me know if any one able to achieve this scenario

Cpt.Whale
  • 10,914
mohan
  • 21

0 Answers0