Hi,
I was wondering how to implement the following Powershell using new Web request and Iterate web request actions. I could go to initial authentication. Then I am confused with iterating the following data that URL gets updated each time. Please advice how to update the connectors.
$RequestBody = @{}
$RequestBody.username = "username"
$RequestBody.password = "password"
$UrlString = "https://somesite/token"
#=======================================
# 1. Authenticate and get the token
#=======================================
$response = Invoke-RestMethod -Method POST -Body $RequestBody -Uri $UrlString -ContentType "application/x-www-form-urlencoded; charset=utf-8"
$headers = @{}
$headers.Authorization = "Bearer " + $response.access_token
$InstanceUrl = $response.instance_url #<--------------- Intitial URL
#=======================================
# 2. Get the data
#=======================================
$UrlString = $InstanceUrl + "QUERY OR REQUEST"
$response = Invoke-RestMethod -Method GET -Headers $headers -Uri $UrlString -ContentType "application/json; charset=utf-8"
$coll += $response.records
while ($response.done -ne $null -And $response.done -ne "done" ) {
#=======================================
# 2. Loop if more data is availabale
#=======================================
$UrlString = $InstanceUrl + $response.nextRecordsUrl # <================= LOOP URL is different
$response = Invoke-RestMethod -Method GET -Headers $headers -Uri $UrlString -ContentType "application/json; charset=utf-8"
}