简体   繁体   中英

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:

definitions: 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

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

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

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);

I use Json.NET to manipulate JSON data. You can find plenty of examples in this library web site .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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