如何使用API​​在TFS中设置区域选择

时间:2017-08-25 12:40:55

标签: tfs

在TFS 2015中的项目中创建区域。添加区域后,该区域中的工作项不会显示在团队的待办事项中。我意识到这是因为,默认情况下,未选择区域,在这种情况下, testarea 未被选中。

testArea is not selected

到目前为止,我是如何创建该区域的:

/*
 * Grabs the necessary connections to the server, as well as the required 
 * clients
 */
static void loadFromServer()
{
    // Connect to TFS
    VssConnection connection = new VssConnection(new Uri(collectionUri), 
    new VssCredentials());

    // Get the project collection that the project is a part of
    TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri
    (collectionUri));

    // Get the version control server from the team project collection
    VersionControlServer vcs = tpc.GetService<VersionControlServer>();

    string projectName = "SomeProject";

    // Get the project from the version control server
    static TeamProject project = vcs.GetTeamProject(projectName);

    // Get the ICommonStructureService to create the area
    static ICommonStructureService commonStructures = 
    tpc.GetService<ICommonStructureService>();
}

/*
 * Create the new area
 */
static void createArea()
{
    // Root area of the project
    NodeInfo rootAreaNode = commonStructures.GetNodeFromPath(projectName 
    + "\\Area");

    string areaName = "SomeArea";
    // Create the new area node
    string newAreaUri = commonStructures.CreateNode(areaName, 
    rootAreaNode.Uri);

    Console.WriteLine(areaName + " created.");
}

如何选择我创建的新区域,以便在其左侧的复选框中显示一个复选标记,允许我的团队在待办事项中查看工作项目?

1 个答案:

答案 0 :(得分:1)

根据我的测试,我们无法选择带有API的区域。我已经提交了user voice here来推荐该功能,您可以将其投票以实现功能。

根据官方文档Work item classification nodes,REST API没有选择/更新区域数据。我们只能Move an area node

但是,使用Fiddler工具跟踪选择区域操作,我们可以获取选择区域时调用的API。要执行post操作,它需要一个令牌,但令牌是动态的。因此,我们无法使用静态令牌调用API来更新区域数据(选择区域)。

enter image description here