从 TFS2015 RestAPI 返回什么对象 [英] What object returns from TFS2015 RestAPI

查看:48
本文介绍了从 TFS2015 RestAPI 返回什么对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 TFS 2015 rest api 来检索构建定义并使用这些调用构建详细信息:

I'm using TFS 2015 rest api in order to retrieve build definitions and builds details using those calls:

定义:http:///tfs/DefaultCollection//_apis/build/definitions?name=ampm&api-version=2.0

definitions: http:///tfs/DefaultCollection//_apis/build/definitions?name=ampm&api-version=2.0

构建:http:///tfs/DefaultCollection//_apis/build/builds?definition=DigitalVault_Automation&statusFilter=completed&$top=10&api-version=2.0

builds: http:///tfs/DefaultCollection//_apis/build/builds?definition=DigitalVault_Automation&statusFilter=completed&$top=10&api-version=2.0

我得到了一个丰富的 JSON,我想知道是否有一个标准类可以将这些 JSON 反序列化为.

I get a rich JSON and I wonder if there is a standard Class that I can deserialize those JSONs to.

虽然在 Microsoft 的指南中找不到任何参考.

Couldn't find any reference in Microsoft's guide though.

推荐答案

您可以使用 install 此 Nuget 包 用于您的项目和包中.这个包中的程序集已经帮你把json数据传输到对应的对象了.例如,要获得有关构建的信息,您可以使用 Microsoft.TeamFoundation.Build.WebApi 程序集.获取构建定义:

You could use install this Nuget package for your project and in the package. The assemblies in this package has already help you transfer the json data to the corresponding object. For example, to get something about build, you could use the Microsoft.TeamFoundation.Build.WebApi assembly. To get a build definition:

var u = new Uri("http://serverName:8080/tfs/MyCollection/");
VssCredentials c = new VssCredentials(new Microsoft.VisualStudio.Services.Common.WindowsCredential(new NetworkCredential("userName", "password", "domain")));
var connection = new VssConnection(u, c);
var buildServer = connection.GetClient<BuildHttpClient>();            
BuildDefinition builddef = buildServer.GetDefinitionAsync("AgileMttGreen",10).Result;
Console.WriteLine(builddef.Name);

这篇关于从 TFS2015 RestAPI 返回什么对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆