Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
173 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 Reply

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...