I have a powershell script see below (that I want to convert for use with FME). I just can't seem to find a suitable way to do it. Been around FME for a while but newish to API integrations. I have an application ID and a secrete key to be used with this.
Any assistance welcome.
---------------------------------------------------------------------------------------------------------
# Get authorisation
$requestHeaders = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$requestHeaders.Add("Content-Type", "application/json")
$requestBody = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$requestBody.Add("ApplicationId", "xxxxxxxxxxxxxxxxxxxxxxxx")
$requestBody.Add("ApplicationSecret", "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12
try {
$authorisationResponse = Invoke-RestMethod 'https://xxxxxxx.xxxxxxxxxx.net/Auth/token' -Method 'POST' -Headers $requestHeaders -Body $($requestBody | ConvertTo-Json)
} catch {
Write-Host "$(Get-Date -Format "dd/MM/yyyy HH:mm") - Authorisation failed. Update abandoned."
break
}
Write-Host "$(Get-Date -Format "dd/MM/yyyy HH:mm") - Authorisation complete."
# Call API for full list of properties
$requestHeaders = New-Object "System.Collections.Generic.DictionaryDiString],[String]]"
$requestHeaders.Add("Authorization", "Bearer $($authorisationResponse.result.token)")
$stopwatch = osystem.diagnostics.stopwatch]::StartNew()
try {
$fullPropertyListResponse = Invoke-RestMethod "https://xxxxx.xxxxxxxxxxxx.net/Legacy/Properties?PageSize=999999&PageNumber=1&SortKey=PropertyNumber&SortOrder=Descending&Filters=HideDefunct=true" -Method 'GET' -Headers $requestHeaders
} catch {
Write-Host "$(Get-Date -Format "dd/MM/yyyy HH:mm") - Full property list failed. Update abandoned."
break
}
$allProperties = $fullPropertyListResponse.result.result
$stopwatch.Stop()
Write-Host "$(Get-Date -Format "dd/MM/yyyy HH:mm") - RunTime $($stopwatch.Elapsed) - $($allProperties.count) properties returned from the API."