Closed robinmalik closed 6 years ago
The problem is in the URI that's generated for subsequent pages. https://gitlab.domain.com/api/v4/users&page=2
is not valid - it is missing the ?
.
If you change line 27 from:
'All' { $Request.URI = '/users' }
to:
'All' { $Request.URI = '/users?' }
If I were to be a pedant, that'd make the first call for a page https://gitlab.domain.com/api/v4/users?
and the ? is not required, but it does fix the problem and returns all results.
The problem should be solved in QueryGitLabAPI on line 63. It tries to catch this case but fails. It then mangles the URL by appending a '&' without the '?' delimiter.
I blame myself for not having more robust testing.
This still seems to be broken. This is what happens on the latest version:
Get-GitLabUser -All -Verbose
VERBOSE: URL: https://domain.com/api/v4/users
VERBOSE: GET https://domain.com/api/v4/users with 0-byte payload
VERBOSE: received 4241-byte response of content type application/json
VERBOSE: GET https://domain.com/api/v4/users?page=2 with 0-byte payload
VERBOSE: received 1393-byte response of content type application/json
I get 7 results. Compare this to the previous code which returns 27 results.
Get-GitLabUser -All -Verbose
VERBOSE: URL: https://domain.com/api/v4/users?
VERBOSE: GET https://domain.com/api/v4/users? with 0-byte payload
VERBOSE: received 4241-byte response of content type application/json
VERBOSE: GET https://domain.com/api/v4/users?&page=2 with 0-byte payload
VERBOSE: received 1393-byte response of content type application/json
The difference is a missing &
symbol in the newer code.
Having run git reset --hard 5fb4549d6d9716819d1783659b7ce4f07d19d617
to try and troubleshoot the projects issue #196, it also seems that Get-GitlabUser -All
works but it doesn't have the &
in the URL query. At this point, I'm confused as to what's changed after commit 5fb4549d6d9716819d1783659b7ce4f07d19d617 to seemingly break things.
1. Get-GitlabUser -All fails with over 20 users.
2. Describe Your Environment
Windows 10 x64 Enterprise Build 1803
PSVersion 5.1.17713.1000
3. Expected Behavior
All users returned.
4.Current Behavior
Followed by 20 users. There are 26 in the system.
5. Possible Solution
Not at this stage. Confirmed all users are returned with https://gitlab.domain.com/api/v4/users?per_page=100.