简体   繁体   English

如何通过C#中的Rest API从TFS Build中获取AssociatedWorkItem?

[英]How to get AssociatedWorkItem from TFS Build via Rest API in C#?

I have some questions about the new tfs rest api :-) 我对新的tfs rest api有一些疑问:-)

first question: The new TFS Rest API interface is really nice, but how can I parse the JSON Object (eg /builds/ list) to a valid C# Object? 第一个问题:新的TFS Rest API接口确实很棒,但是如何将JSON对象(例如/ builds / list)解析为有效的C#对象? Is there a Object in the Microsoft references, which I can use or do i have to string of Json? Microsoft引用中是否有对象,我可以使用它,还是必须对Json进行字符串处理?

second question: I need the associated work items of the current TFS build (by Build ID?), it was easy to do it in the old TFS C# API. 第二个问题:我需要当前TFS构建的相关工作项(通过Build ID?),在旧的TFS C#API中很容易做到。 Is it possible for the new rest api as well? 新的rest api也可能吗?

  1. You could 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数据传输到相应的对象。 Check this case: What object returns from TFS2015 RestAPI 检查这种情况: TFS2015 RestAPI返回什么对象

  2. Yes. 是。 You can get the associated work items of the current TFS build with REST API: https://www.visualstudio.com/en-us/docs/integrate/api/build/builds#work-items 您可以使用REST API获取当前TFS构建的关联工作项: https : //www.visualstudio.com/zh-cn/docs/integrate/api/build/builds#work-items

The REST API is as below: REST API如下:

POST https://{instance}/DefaultCollection/{project}/_apis/build/builds/{buildId}/workitems?api-version={version}

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

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