Я не могу понять, в чем проблема с кодом в течение нескольких дней ..
Ребята, посмотрите, что я сделал неправильно?
Название организации и проекта указаны в коде правильно.
Это сообщение об ошибке, отображаемое в PowerShell ISE:
Invoke-RestMethod: Невозможно отправить тело содержимого с этим типом глагола. В
\ Project \ DevopTask.ps1: 47 char: 17
+ ... $ response = Invoke-RestMethod -Uri $ url -headers $ headers -Method Get ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
+ CategoryInfo: NotSpecified: (:) [Invoke-RestMethod], ProtocolViolationException
+ FullyQualifiedErrorId: System.Net.ProtocolViolationException, Microsoft.PowerShell.Commands.InvokeRestMet
hodCommand
$collectionuri = $Env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI
$token = $Env:SYSTEM_ACCESSTOKEN # need to configure build to allow passing OAuth tokens
$basicAuth = "{0}:{1}" -f '', 'token~~fdsafdsa'
$basicAuth = [System.Text.Encoding]::UTF8.GetBytes(":$($basicAuth)")
$basicAuth = [System.Convert]::ToBase64String($basicAuth)
$headers = @{Authorization=("Basic {0}"-f $basicAuth)}
$WorkItemType = 'Recently updated'
$url = $collectionuri + 'https://dev.azure.com/{OrganizationName}/{ProjectName}/_apis/wit/queries/test/wiql?api-version=5.0'
$WIQL_query = "select [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State], [System.IterationPath] from WorkItems where [System.TeamProject] = @project and [System.Id] in (@recentProjectActivity) and not [System.State] in ('Closed', 'Inactive', 'Completed') and [System.IterationPath] Under 'Sprint number two' order by [System.ChangedDate] desc"
$body = @{ query = $WIQL_query }
$bodyJson=@($body) | ConvertTo-Json
$response = Invoke-RestMethod -Uri $url -headers $headers -Method Get -ContentType "application/json" -Body $bodyJson
$workitems = $response.workItems
Write-Host "Found" $workitems.Count "work items of type:" $WorkItemType