Share via

DevOps Rest API - How can I query Work items returning a field based on a query?

John Fuex 1 Reputation point
2020-09-07T02:24:02.773+00:00

I'm trying to write a dashboard widget that will calculate and display aggregates on a numeric field (e.g. Story points) beyond what is available in the out-of-the-box Query/Chart functionality.

My solution so far involves using the Work item tracking API to take a query configured by the user to define the work items to include in the aggregation.

At first I tried the queryById which seemed perfect except that it only returns the ID of the work items for the query and I need other fields.
Then I reasoned that I could fed the IDs back into getWorkItems to return those work items with the additional fields, and it worked fine.

So this all worked fine and returned what I needed, BUT here's the problem. The REST API call to getWorkItems requires a string of Work Item IDs, in some cases it could be thousands or tens of thousands of items which will probably exceed the limit on the querystring for a get request.

So here's what I'm hoping for: (one of the following)
(A) A way to call something that works like QueryById but returns additional fields in the result.
(B) A way to do the aggregation on the server instead of pulling down all the work items. I thought maybe a custom WIQL query, but it doesn't appear to have any operators like SUM, AVG, etc. Is it possible through one of the API's to just run a tSQL query against the work items?

Thanks for any help you can offer. If it is not possible to do either of the above consider it a feature request

Community Center | Not monitored
0 comments No comments

1 answer

Sort by: Most helpful
  1. Dylan Zhu-MSFT 6,436 Reputation points
    2020-09-07T03:41:17.997+00:00

    Hi JohnFuex,

    According to your description, this issue is more related to extension development for azure devops, which is not supported in Microsoft Q&A forum. So we suggest you could move to stack overflow with azure-devops and azure-devops-rest-api tag, and then the community members will provide dedicated support for you.

    Best Regards,
    Dylan

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.