Closed ntbritton closed 4 years ago
Here is how i did it in powershell. I was not sure how else is the best way to get this added to the examples for everyone to see.
$allPages = New-Object System.Collections.ArrayList @() $page = 0
do { $page = $page + 100 write-host "Current page processing is $page" $uri = $basepath + "/assets?page%5Boffset%5D=$page&page%5Blimit%5D=$itemlimit&sort=-lastDiscoveredTime"
$response = Invoke-WebRequest -Uri $uri
-Method GET -ContentType $content_type
-Headers $headers
$content = (ConvertFrom-Json -InputObject $response)
foreach ($contentpage in $content.data.attributes) {
$allPages.Add($contentpage)|Out-Null
}
$allPages.Count
} while ($content.links.self.href -ne $content.links.last.href)
$allPages.Count
There is also: $content.meta
pagination
----------
@{next=10; pages=4; last=30; offset=0; limit=10; count=34; page=0; first=0}
That would work to loop through all the pages as well. I had not seen that one.
Can we get a powershell and ansible example of how to return all pages to a var?