Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
171 views
in Technique[技术] by (71.8m points)

What is the max number of work items returned from this Azure Devops API?

I am using the API listed here: Get Work Items between Builds to make an inhouse product that lets us quickly build release notes for each version of our product. But I seem to get a total return value of 50 often. And we are now noticing that some results are left off. Is 50 the limit that this API returns? I dont see any indications of this on the page.

question from:https://stackoverflow.com/questions/65852562/what-is-the-max-number-of-work-items-returned-from-this-azure-devops-api

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can retrieve more work items use the $top filter in rest api Get Work Items between Builds.

For below example in powershell script:

# special character `$` in `$top` needs to be escaped.
$url = "https://dev.azure.com/ORG/PROJ/_apis/build/workitems?fromBuildId=8913&toBuildId=8917&`$top=200&api-version=6.1-preview.2"

$PAT="....."
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($PAT)"))

$result = Invoke-RestMethod -Uri $url -Headers @{authorization = "Basic $base64AuthInfo"} -Method get

$result.count

Note: You need to escape the special character $ in $top filter by adding a back tick "'".

See below result from my test. I can got all the related work items. enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...