Skip to content

Bug in Invoke-vRARestMethod auto-pagination handling when fetching policies #285

Description

@tocano33

Steps to reproduce

$response = Invoke-vRARestMethod -Method GET -Uri "/policy/api/policies"

Expected behavior

Return the first page of policies - or, ideally, cycle through all pages and return all the policies

Actual behavior

Gets stuck in infinite loop fetching data.

I believe this is because the /policy/api/policies endpoint returns the standard paginated portion of the payload, including the property 'last' which is used by Invoke-vRARestMethod to identify paginated data and auto-request the next page by using the 'page' parameter. Except that the /policy/api/policies endpoint appears to ignore the 'page' parameter (using $skip and $top instead), so it continually returns the same set of results and so 'last' is never reached.

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.2.7
PSEdition                      Core
GitCommitId                    7.2.7
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

> $vRAConnection
Server             : https://[FQDN]
Token              : eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEwMTcwNjYzODc5MTk4NDA1NzcxIn0...K7ZYqD8jPfTqubk5080wklQJ6SvqNCjLFUe08GsWA
RefreshToken       : Ap1X0X...4V9ibSBK
APIVersion         : 2021-07-15
SignedCertificates : True
SslProtocol        : Default

> (Get-Module PowervRA).Version

Major  Minor  Build  Revision
-----  -----  -----  --------
5      2      0      -1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions