如何在 TFS 2015 Update 3 中获取标签列表

How to fetch the list of Tags in TFS 2015 Update 3

有没有办法获取为团队项目创建的标签列表,基本上我们需要创建日期、用户创建等信息

我们可以使用 TFS RestApi 获取这些信息吗?如果是这样,如果提供代码片段将会很有帮助。

有一个 REST API 来管理 Tags,但没有按照您的要求审核信息。

如果您想了解如何调用 REST API,可以从 Get started 页面开始找到大量资源。

没有用户创建的信息,可以到collection数据库的dbo.tbl_TagDefinitiontable中查看。

要获取标签列表,可以参考Giulio的回答,例如:

[collection URL]/_apis/tagging/scopes/[Team Project ID]/tags?api-version=1.0

要获取团队项目 ID,您可以调用此 REST API:

[Collection URL]/_apis/projects?api-version=1.0

简单的 C# 代码:

String MyURI = "[collection URL]/_apis/tagging/scopes/f593de42-d419-4e07-afc7-1f334077c212/tags?api-version=1.0";
            WebRequest WReq = WebRequest.Create(MyURI);
            WReq.Credentials =
                new NetworkCredential("[user name]", "[password]", "[domain"");

            WebResponse response = WReq.GetResponse();
            Console.WriteLine(((HttpWebResponse)response).StatusDescription);
            // Get the stream containing content returned by the server.
            Stream dataStream = response.GetResponseStream();
            // Open the stream using a StreamReader for easy access.
            StreamReader reader = new StreamReader(dataStream);
            // Read the content.
            string responseFromServer = reader.ReadToEnd();
            // Display the content.
            Console.WriteLine(responseFromServer);