Fix query batch processing (#2769)

Co-authored-by: Wes Haggard <Wes.Haggard@microsoft.com>
This commit is contained in:
Azure SDK Bot 2021-08-18 14:22:20 -07:00 committed by GitHub
parent 8a2c551230
commit 8db9c0b223
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,7 +62,7 @@ function Invoke-Query($fields, $wiql, $output = $true)
-Uri "https://dev.azure.com/azure-sdk/Release/_apis/wit/wiql/?`$top=10000&api-version=6.0" `
-Headers (Get-DevOpsRestHeaders) -Body $body -ContentType "application/json" | ConvertTo-Json -Depth 10 | ConvertFrom-Json -AsHashTable
if ($response -isnot [HashTable] -or !$response.ContainsKey("workItems")) {
if ($response -isnot [HashTable] -or !$response.ContainsKey("workItems") -or $response.workItems.Count -eq 0) {
Write-Verbose "Query returned no items. $wiql"
return ,@()
}
@ -83,11 +83,11 @@ function Invoke-Query($fields, $wiql, $output = $true)
Write-Verbose "Pulling work items $uri "
$batchResponse = Invoke-RestMethod -Method GET -Uri $uri `
-Headers $headers -ContentType "application/json" -MaximumRetryCount 3 | ConvertTo-Json -Depth 10 | ConvertFrom-Json -AsHashTable
-Headers (Get-DevOpsRestHeaders) -ContentType "application/json" -MaximumRetryCount 3 | ConvertTo-Json -Depth 10 | ConvertFrom-Json -AsHashTable
if ($batchResponse.value)
{
$batchResponse.value | % { $workItems += $_ }
$batchResponse.value | ForEach-Object { $workItems += $_ }
}
else
{