Get more than 100 Releases
_Originally posted by @stefanstranger in https://github.com/DarqueWarrior/vsteam/issues/35
The REST API includes an x-ms-continuationtoken response header that, unfortunately, is not readily accessible when using Invoke-RestMethod. In order to access the response header(s) it may be necessary to use Invoke-WebRequest (or similar).
Steps to reproduce
Get-VSTeamRelease -definitionId 12 -Top 200
Get-VSTeamRelease -definitionId 12 -ContinuationToken '???'
Expected behavior
- -Top 200 should return 200
- Results should always include a ContinuationToken (if the response headers include x-ms-continuationtoken) to use in subsequent calls in order to retrieve all releases.
Actual behavior
- -Top 200 returns 100
- No ContinuationToken is returned, therefore it is not possible to request another page.
Environment data
OS
- [ ] macOS
- [X] Windows
- [ ] Linux
Server
- [ ] TFS 2017
- [ ] TFS 2018
- [ ] Azure DevOps Server
- [X] Azure DevOps Service
> Get-VSTeamAPIVersion
Name Value
---- -----
ServiceFabricEndpoint 5.0-preview
Build 5.0
ExtensionsManagement 5.1-preview
Release 5.1-preview
Version VSTS
MemberEntitlementManagement 5.1-preview
Packaging 5.1-preview
Tfvc 5.0
Git 5.1-preview
Core 5.0
Graph 5.1-preview
DistributedTask 5.0-preview
> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.17134.765
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.765
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Thanks for the detailed issue. I will ping the team and see what we can do about this.
So I have good news and bad news. Good news is there is a thread going internally to get to the bottom of this. Bad news this API call for releases is not implemented correctly at the moment. Once it is corrected we can add support.
This change is going to take a bit of work. The code currently uses Invoke-RestMethod and only in PowerShell Core does that call give you access to the returned headers. I just did some quick testing and I can change the code to still work in 5.x but you can't get to the headers there. This feature would only be supported in 6 or later.
Even with that it will take time to surface the continuation token up the stack so the caller will have access to it to pass to subsequent calls to get the rest of the items.
There is a second method of paging at APIs in AzD can support using $Top and $Skip. However, the Release API only supports $Top at the moment and not $Skip. I have an email into the team to see if they plan to add the $Skip parameter support as well. If so that will be a much faster fix.
any update on that? I can try to implement something if the team was already able to fix the issue.
I rolled my own Get-VSTSRelease that indirectly calls Invoke-WebRequest as a workaround, but the effort to integrate it with (or conditionally circumvent) vsteam's _callAPI is a bit daunting.
Agreed. I am looking into other options as well. There have been internal threads on how the API has implemented this.
Are there any plans to move to PSCore? That would also solve the problem, wouldn't it?