I have requested to list out all the NPM packages available in the Azure Artifact location.
Able to list from project scoped feed and unable to list NPM packages from Organization scoped feeds. Please help
I have requested to list out all the NPM packages available in the Azure Artifact location.
Able to list from project scoped feed and unable to list NPM packages from Organization scoped feeds. Please help
2
Answers
Below PowerShell script helped me to pull the list using PAT.
function GetUrl() { param( [string]$orgUrl, [hashtable]$header, [string]$AreaId )
}
$orgUrl = "https://dev.azure.com/myorg" $personalToken = "mytoken"
Write-Host "Initialize authentication context" -ForegroundColor Yellow $token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($personalToken)")) $header = @{authorization = "Basic $token"}
DEMO 1 List of projects
Write-Host "Project List" #packaging ID refer https://learn.microsoft.com/en-us/azure/devops/extend/develop/work-with-urls?view=azure-devops&tabs=http&viewFallbackFrom=vsts $coreAreaId = "7ab4e64e-c4d8-4f50-ae73-5ef2e21642a5" $tfsBaseUrl = GetUrl -orgUrl $orgUrl -header $header -AreaId $coreAreaId
https://learn.microsoft.com/en-us/rest/api/azure/devops/core/projects/list?view=azure-devops-rest-5.1
project name should be specified for project based feed
#$projectsUrl = "$($tfsBaseUrl)Project/_apis/packaging/Feeds/{FeedName}/packages?api-version=6.0-preview.1" #$projectsUrl = "$($tfsBaseUrl)/_apis/packaging/Feeds/platform-template/packages?includeAllVersions=True&api-version=6.0-preview.1"
No project name should be specified for Organization based feed
$projectsUrl = "$($tfsBaseUrl)/_apis/packaging/Feeds/{FeedName}/packages?api-version=6.0-preview.1" $projects = Invoke-RestMethod -Uri $projectsUrl -Method Get -ContentType "application/json" -Headers $header
$projects.value | ForEach-Object { write-output "Package Name:" $.name | Out-File "D:File.txt" -Append $projects2Url = "https://feeds.dev.azure.com/pdidev/apis/packaging/Feeds/{FeedName}/Packages/$($.id)/versions?api-version=6.0-preview.1" $project2s = Invoke-RestMethod -Uri $projects2Url -Method Get -ContentType "application/json" -Headers $header $project2s.value | ForEach-Object { write-output $.version `n| Out-File "D:file.txt" -Append } }
To list out all the packages available in the Azure Artifact location, use the below REST API
To get the list of Package Versions, use the below API
npm packages
Version, usePlease refer Artifacts – Npm for more information