Trying to fetch the response from the API. Sometimes output json file get generated with proper json with start and end brasis but sometimes end curley brasis “}” is missing in output file.
Expected :
{
…
…
}
Current Result:
{
…
…
Script :
…
…
…
$QueryResults = @()
Invoke REST method and fetch data until there are no pages left.
do {
$Results = Invoke-RestMethod -Headers $Headers -Uri $uri -UseBasicParsing -Method “GET” -ContentType “application/json”
if ($Results.value) {
$QueryResults += $Results.value
} else {
$QueryResults += $Results
}
$uri = $Results.'@odata.nextLink'
} until (!($uri))
# Return the result.
$QueryResults | ConvertTo-Json -depth 100 | Out-File "C:\AzureAD.json"
Set-AzureStorageBlobContent -File "C:\AzureAD.json" -Container $ContainerName -Blob "SecurityGroups/AzureAD.json" -Context $Ctx -Force
Can someone help me out on this.