We are using a self-hosted instance of ProGet 22.0.26. We are trying to download all the packages from all feeds, and therefore need to use the API.
We have tried using the pgutil CLI, the Native API, HTTP Methods, and the .NET Inedo.ProGet nuget package, but none of them work.
If I try to browse "https://#####/api/management/feeds/list" on my browser, I get "Persisted object is not a FeedConfig."
If I try to use the nuget package, set up as follows:
var creds = new ProGetApiKeyAuthentication("#####");
var proGetClient = new ProGetClient("https://#####", creds);
var createFeedResponse = await proGetClient.CreateFeedAsync("test-feed-from-dotnet", "nuget", CancellationToken.None);
I get
Unhandled exception. Inedo.ProGet.ProGetClientException: Server responded with BadRequest (400): Expected content-type application/json.
at Inedo.ProGet.ProGetClient.CheckResponseAsync(HttpResponseMessage response, CancellationToken cancellationToken)
at Inedo.ProGet.ProGetClient.CreateFeedAsync(String feedName, String feedType, CancellationToken cancellationToken)
at NugetSync.ConsoleApp.Clients.TrakaProgetClient.ListPackagesAsync(String feed) in C:\Users\frcamp\RiderProjects\nuget-sync\src\NugetSync.ConsoleApp\Clients\TrakaProgetClient.cs:line 13
at Program.<Main>$(String[] args) in C:\Users\frcamp\RiderProjects\nuget-sync\src\NugetSync.ConsoleApp\Program.cs:line 15
at Program.<Main>(String[] args)
If I try to list the feeds:
var feedsResponse = proGetClient.ListFeedsAsync();
var feeds = new List<ProGetFeed>();
await foreach (var feed in feedsResponse)
{
feeds.Add(feed);
}
I get:
Unhandled exception. System.Net.Http.HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error).
at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
at System.Net.Http.Json.HttpClientJsonExtensions.<FromJsonStreamAsyncCore>g__Core|7_0[TValue](HttpClient client, Uri requestUri, JsonTypeInfo`1 jsonTypeInfo, CancellationToken cancellationToken)+MoveNext()
at NugetSync.ConsoleApp.Clients.TrakaProgetClient.ListPackagesAsync(String feedName) in C:\Users\frcamp\RiderProjects\nuget-sync\src\NugetSync.ConsoleApp\Clients\TrakaProgetClient.cs:line 16
at NugetSync.ConsoleApp.Clients.TrakaProgetClient.ListPackagesAsync(String feedName) in C:\Users\frcamp\RiderProjects\nuget-sync\src\NugetSync.ConsoleApp\Clients\TrakaProgetClient.cs:line 16
at Program.<Main>$(String[] args) in C:\Users\frcamp\RiderProjects\nuget-sync\src\NugetSync.ConsoleApp\Program.cs:line 15
at Program.<Main>(String[] args)
When I try to make requests from postman, I always get a 401, no matter if I put the API Key in the headers or query.
I have also tried one of the example PowerShell scripts on the docs:
$feedName = "#####"
$apiUrl = "https://#####/api/packages/$feedName/latest"
$apiKey = "######"
$queryParams = @{
stableOnly = "true"
}
$headers = @{
"X-API-Key" = $apiKey
}
$response = Invoke-RestMethod -Uri $apiUrl -Headers $headers -Method Get -Body $queryParams
foreach ($package in $response) {
Write-Host "Package Name: $($package.name)"
Write-Host "Latest Version: $($package.version)"
Write-Host "--------------------"
}
But always get a 401.
I have also tried to use a pseudo key (username:password) but I get the same exact results with all methods (pgutil, nuget package, HTTP methods).
How can we call the API for ProGet?