如何使用VSO/VSTS Rest API执行自定义查询?

编程入门 行业动态 更新时间:2024-10-14 12:22:43
本文介绍了如何使用VSO/VSTS Rest API执行自定义查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我希望能对使用REST API执行自定义VSO查询提供一些帮助.但是我在构造URL时遇到了麻烦.我一直在使用以下文档来构造我想要的东西.

I was hoping for some help executing a Custom VSO query using the REST API. But I am having trouble constructing the URL. I have been using the Following Documentation to construct what I want.

www.visualstudio/zh-CN/integrate/api/wit/wiql

我的问题是我不确定自己如何存储查询或在哪里存储查询.

My issue is that I am not sure how or where to store the query it self.

{instance}/defaultcollection/[{project}/] _apis/wit/wiql?api-version = {version}

{instance}/defaultcollection/[{project}/]_apis/wit/wiql?api-version={version}

给出的例子是

fabrikam.visualstudio/DefaultCollection/Fabrikam-Fiber-Git/_apis/wit/wiql?api-version = 1.0

但是,这没有显示如何或在何处存储查询.

But this doesn't show how or where to store the query.

我已经能够使用存储的查询执行相同的查询,但是结果不会返回我在VSO中的查询中设置的列.

I have been able to perform the same query using a stored query, however, the results don't return the columns I set up in the query in VSO.

推荐答案

用于执行查询的其余端点是POST方法,并且期望JSON正文包含键 query .

The rest endpoint for executing query is a POST method and expects a JSON body to contain a key query.

因此,要执行自定义查询,您将对 {instance}/defaultcollection/[{project}/] _apis/wit/wiql?api-version = {version} ,其中 content-type 头设置为 application/json ,并且请求的主体采用以下格式.

So to execute a custom query, you will do a POST call to {instance}/defaultcollection/[{project}/]_apis/wit/wiql?api-version={version} with content-type header set to application/jsonand the body of the request in the below format.

{ "query": string }

示例:

POST fabrikam.visualstudio/DefaultCollection/Fabrikam-Fiber-Git/_apis/wit/wiql?api-version=1.0 Content-Type: application/json

身体:

{ "query": "Select [System.WorkItemType],[System.Title],[System.State],[Microsoft.VSTS.Scheduling.Effort],[System.IterationPath] FROM WorkItemLinks WHERE Source.[System.WorkItemType] IN GROUP 'Microsoft.RequirementCategory' AND Target.[System.WorkItemType] IN GROUP 'Microsoft.RequirementCategory' AND Target.[System.State] IN ('New','Approved','Committed') AND [System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward' ORDER BY [Microsoft.VSTS.Common.BacklogPriority] ASC,[System.Id] ASC MODE (Recursive, ReturnMatchingChildren)" }

更多推荐

如何使用VSO/VSTS Rest API执行自定义查询?

本文发布于:2023-11-28 16:07:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643070.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   如何使用   VSO   VSTS   Rest

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!