I am trying to download a file from from Azure Artifact package using their Rest API.
wget --header="Authorization: Basic $PAT" "$URL" -O $filename
I am getting error message
ERROR:403 Server failed to authenticate the request. Make sure the value of authorization header is formed correctly including the signature.....
I can download the file Azure Artifact package using the Rest API in PowerShell.
The following is a sample to download a NuGet package with NuGet - Download Package. If you want to download other types, you can change the apiUrl
with the one you need.
$pat=""
$filename=""
$apiUrl ="https://pkgs.dev.azure.com/{organization}/{project}/_apis/packaging/feeds/{feedId}/nuget/packages/{packageName}/versions/{packageVersion}/content?api-version=6.1-preview.1"
# Use Invoke-RestMethod to download the package
Invoke-RestMethod -Uri $apiUrl -Headers @{ Authorization = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$pat")) } -OutFile $filename
# Check if the download was successful
if ($?) {
Write-Host "Package downloaded successfully: $filename"
} else {
Write-Host "Error downloading package."
}