Here’s an example using Powershell:
For($i=0;$i -le $Pagecount;$i++){
#Search query
$searchBody= '{“query”: {“query”: “created:[now-1d TO now] AND type:*”},
“sort”:[“id”],
“searchAfter”:[“’ + $searchAfter + '”]
}’
write-output “Page $i of $Pagecount; Last ID from previous set: $searchAfter”
$Results = Invoke-WebRequest -Method POST -Uri https://$($org).api.identitynow.com/v3/search/events?limit=1 -Headers @{Authorization= “Bearer $token”} -body $searchBody -ContentType “application/json”
$Content= $Results.Content.Substring($Results.content.indexof(“[”)+1, $Results.content.LastIndexOf(“]”)-1)
$Content | out-file “C:\Users\justin.haines\OneDrive - Optiv Security Inc\xyz\Scripts\Events.json” -Append
$searchAfter= $Content.substring($Content.IndexOf(“id`”:")+6,31)
}