I have a REST API from where I need to get data downloaded, but when I hit api it shows data for one page but there are many pages of data, so overtime I need to edit the query to go to next page.
below is the sample of result, please note the api only accept maximum 300 records in a single page,
page_count : 155
page_number : 1
page_size : 300
to get the next page, I have to use ‘&page_number=2’ in the query, below is the sample query
Invoke-RestMethod ‘https://site.us/v2/users?page_size=300&page_number=2’ -Method ‘GET’ -Headers $headers -Body $body
I would like to automate the query with a loop and I am bit confused how to do that, I was trying to use the ‘For’ loop but the output is jason when I store it I am not getting the data into a good format, could any one help here?