【问题标题】:Using TFS API to get work items by a field instead of ID使用 TFS API 通过字段而不是 ID 获取工作项
【发布时间】:2018-09-26 19:15:21
【问题描述】:

我想使用 TFS API 来获取工作项,但它似乎只支持通过提供 ID 字段来获取工作项。

我正在制作一个门户网站,其中一个普通帐户必须通过例如分配/区域字段/项目名称来查找工作项。

我在官方页面上找不到任何文档,这可能吗?

【问题讨论】:

    标签: api tfs


    【解决方案1】:

    如果您使用 VSTS 或某些较新版本的 TFS,您可以使用 WIQL REST API https://www.visualstudio.com/en-us/docs/integrate/api/wit/wiql 这里也有关于如何使用的代码示例https://github.com/Microsoft/vsts-restapi-samplecode/commit/a27a0c48b81f1ba74ea638e8bae46072f645e8af

    【讨论】:

    • 我发现我确实可以使用 WIQL 通过 http 发送查询,或者使用 http 来“联系”存储在 TFS 中的查询!
    【解决方案2】:

    仅通过字段(Id 除外)获取工作项并不能保证该工作项的唯一性。可以有更多具有该值的工作项。

    【讨论】:

      【解决方案3】:

      这是一个例子:

      Wiql wiql = new Wiql()
          {
              Query = "Select [State], [Title] " +
                      "From WorkItems " +
                      "Where [Work Item Type] = 'Bug' " +
                      "And [System.TeamProject] = '" + project + "' " +
                      "And [System.State] <> 'Closed' " +
                      "Order By [State] Asc, [Changed Date] Desc"
          };
      //create instance of work item tracking http client
      using (WorkItemTrackingHttpClient workItemTrackingHttpClient = new WorkItemTrackingHttpClient(uri, credentials))
      {
          //execute the query to get the list of work items in the results
          WorkItemQueryResult workItemQueryResult = workItemTrackingHttpClient.QueryByWiqlAsync(wiql).Result;
      }
      

      【讨论】:

        猜你喜欢
        • 2018-09-08
        • 2018-11-16
        • 1970-01-01
        • 2012-08-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-12-06
        • 2018-07-24
        相关资源
        最近更新 更多