我使用下面的http请求成功地获取了项目下的工作项。
http://dev.azure.com/{organization}/{project}/_apis/wit/reporting/workitemrevisions?includeLatestOnly=true&api-version=5.0-preview.2
同样,我需要获取团队工作项,这是我使用的请求。
http://dev.azure.com/{organization}/{project}/{team}/_apis/wit/reporting/workitemrevisions?includeLatestOnly=true&api-version=5.0-preview.2
但是,我没有得到工作项。谁能帮我一下语法?
您可以使用以下命令获取团队任务板上的工作项:
GET https://dev.azure.com/{organization}/{project}/{team}/_apis/work/taskboardworkitems/{iterationId}?api-version=6.0-preview.1
和在团队迭代中使用:
GET https://dev.azure.com/{organization}/{project}/{team}/_apis/work/teamsettings/iterations/{iterationId}/workitems?api-version=6.0-preview.1
你也可以做一个WIQL查询:
$AreaPath = "{Project}{PathYou'reInterestedIn}"
# Example WIQL gets all User Stories and Bugs that are not removed
$wiql = @"
SELECT
[System.Id]
FROM workitems
WHERE
[System.TeamProject] = '$($AreaPath.Split("")[0])'
AND [System.AreaPath] UNDER '$($AreaPath.Replace("", "\"))'
AND [System.State] <> 'Removed'
AND [System.WorkItemType] IN ('User Story', 'Bug')
ORDER BY [System.ChangedDate] DESC
"@
$uri = "https://dev.azure.com/{org}/_apis/wit/wiql?api-version=6.1-preview.2"
# add your access token to the headers
$headers = @{ Authorization = "Basic " + + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$YourAccessTokenValue"))
# I wrote the WIQL to be readable - this makes it suitable for a JSON request
$query = @{ query = ($wiql.split([System.Environment]::NewLine) | `
ForEach-Object { "$($_.Trim())" }) -join " " } | `
ConvertTo-Json
$workItemList = (Invoke-RestMethod -Uri $uri -Headers $headers -Method Post -Body $query).workItems