I currently have a Powershell script to fetch orders through a REST API Call.
The script (1) Uses the INVOKE-ResetMethod
for the API call, then (2) uses the Export-CSV
cmdlet to save the results in a CSV file, which works fine:
$uri = "https://api.SomeWebisite.com/api/orders?limit=1000"
$headers = @{
'Content-Type' = 'application/json'
'Authorization' = 'Bearer SomeTokenKey'
'Accept'= 'application/json'
}
Invoke-RestMethod -Uri $uri -Method GET -Headers $headers -Body $body | select -expand data | select * | export-csv c:\extracts\orders.csv -notype -Force
The problem is, the provider has a 1000 record return limit, which doesn't work for us, as we need all orders in the dataset.
What would be the most efficient/appropriate way to retrieve the full recordset & and have all orders reside in a single CSV file?