TeamFoundationServer。[扩展]客户端:通过我的订阅

时间:2018-03-08 05:35:43

标签: c# tfs2017

我想通过.NET client libraries for VSTS (and TFS)访问和更改我的TFS通知。例如,我能够获得给定变更集编号的变更集详细信息,如下所示:

TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("http://..."));
tpc.EnsureAuthenticated();
var vcs = tpc.GetService<VersionControlServer>();
var changeset = vcs.GetChangeset(378418);

我希望能够在同一庄园中访问我的通知

var ns = tpc.GetService<NotificationSubscription>();

ns为空,所以可能不是这样的。我该怎么做呢?

1 个答案:

答案 0 :(得分:1)

您可以将TFS rest api用于update an existing Notification subscription

PATCH http://TFS2017:8080/tfs/DefaultCollection/_apis/notification/subscriptions/{subscriptionId}?api-version=3.2-preview

Content-Type: application/json

{
 ...
}

我已经在我身边测试过,它正在发挥作用。

Rest Api比SOAP api更简单。要使用SOAP api,您需要使用GetService<IEventService>,请查看此案例以获取更多信息:TFS 2015 Alert API: Create an alert for Team or TFS Group