简体   繁体   English

TFS2015 RestAPI返回什么对象

[英]What object returns from TFS2015 RestAPI

I'm using TFS 2015 rest api in order to retrieve build definitions and builds details using those calls: 我使用TFS 2015 rest api来检索构建定义并使用这些调用构建详细信息:

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

builds: http:///tfs/DefaultCollection//_apis/build/builds?definition=DigitalVault_Automation&statusFilter=completed&$top=10&api-version=2.0 内部版本:http:/// tfs / DefaultCollection // _ apis / build / builds?definition = DigitalVault_Automation&statusFilter = completed&$ top = 10&api-version = 2.0

I get a rich JSON and I wonder if there is a standard Class that I can deserialize those JSONs to. 我得到了一个丰富的JSON,我想知道是否存在可以将这些JSON反序列化的标准类。

Couldn't find any reference in Microsoft's guide though. 不过,在Microsoft指南中找不到任何参考。

You could use install this Nuget package for your project and in the package. 您可以在项目中和程序包中安装此Nuget程序包。 The assemblies in this package has already help you transfer the json data to the corresponding object. 此程序包中的程序集已经帮助您将json数据传输到相应的对象。 For example, to get something about build, you could use the Microsoft.TeamFoundation.Build.WebApi assembly. 例如,要获得有关构建的一些信息,可以使用Microsoft.TeamFoundation.Build.WebApi程序集。 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);

I use Json.NET to manipulate JSON data. 我使用Json.NET来处理JSON数据。 You can find plenty of examples in this library web site . 您可以在此图书馆网站上找到大量示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM