Skip to content

Invoke-RestMethod -FollowRelLink should return a single array of objects #5526

@dddugan

Description

@dddugan

Invoke-RestMethod with the -FollowRelLink parameter correctly retrieves additional pages of results from REST services. However, the return is an array of pages rather than one array of all results.

Steps to reproduce

PS /> $apikey = 'MYAPIKEYHERE'
PS /> $headers = @{'Accept'='application/json';'Content-Type'='application/json';'Authorization'="SSWS $apikey"}
PS />
PS /> $users = Invoke-RestMethod -Uri 'https://MYORGNAME.okta.com/api/v1/users/?filter=status eq "ACTIVE"&limit=10' -Method GET -Headers $headers -FollowRelLink -MaximumFollowRelLink 3
PS />
PS /> $users.Count
3
PS /> $users.Item(0).Count
10
PS /> $users.Item(1).Count
10
PS /> $users.Item(2).Count
10
PS />

Expected behavior

Invoke-RestMethod should return a single array of objects instead of an array of arrays (pages).

PS /> $users.Count
30

Actual behavior

Invoke-RestMethod returns an array of arrays (pages).

Environment data

PS /> $PSVersionTable                                                                                                   
Name                           Value
----                           -----
PSVersion                      6.0.0-rc
PSEdition                      Core
GitCommitId                    v6.0.0-rc
OS                             Linux 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


PS />

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-AnsweredThe question is answered.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions