【问题标题】:TFS REST API - Get allowed values of fieldTFS REST API - 获取字段的允许值
【发布时间】:2017-03-14 22:28:13
【问题描述】:

我需要使用针对特定工作项类型的 TFS 2015 REST API 获取字段(不在全局列表中)中的允许值列表。我知道我可以使用 Get a work item field 获取有关字段的信息,但这似乎没有给我响应中允许的值。

{
  "name": "Iteration Path",
  "referenceName": "System.IterationPath",
  "type": "treePath",
  "readOnly": true,
  "supportedOperations": [
    {
      "referenceName": "SupportedOperations.Under",
      "name": "Under"
    },
    {
      "referenceName": "SupportedOperations.NotUnder",
      "name": "Not Under"
    },
    {
      "referenceName": "SupportedOperations.Equals",
      "name": "="
    },
    {
      "referenceName": "SupportedOperations.NotEquals",
      "name": "<>"
    },
    {
      "referenceName": "SupportedOperations.In",
      "name": "In"
    }
  ],
  "url": "https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/wit/fields/System.IterationPath"
}

看起来像 someone on the MSDN forums posted this 早在 6 月,但我想再次检查这是否仍然不可用。

【问题讨论】:

    标签: c# rest tfs azure-devops


    【解决方案1】:

    REST API 仍然不支持在字段中获取允许的值。下面的网站已经有这个功能的 UserVoice,你可以投票:

    https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/14839494-visual-studio-rest-api-support-to-fetch-the-list-o

    目前,您只能使用旧的 .net API 通过获取类 FieldDefinition 的实例并引用 AllowedValues 属性来获取 allowedvalues。

    【讨论】:

    • 自请求此功能以来已有两年多的时间。 MSFT 的任何人都没有发表任何回应。
    【解决方案2】:

    据我了解,现在从 4.1 版开始支持此功能

    您可以在工作项的上下文中获取给定字段的允许值列表。

    示例响应如下:

    {
      "alwaysRequired": false,
      "defaultValue": null,
      "allowedValues": [
        {
          "displayName": "Jamal Hartnett",
          "id": "df828ec3-71d8-6e69-9afd-e736c5a32145",
          "uniqueName": "fabrikamfiber4@hotmail.com",
          "descriptor": "s2s.M2FjODRhZmItYWIwNC00ZWM0LWEyZWItOGEyYWJmNGJlNDQ3QDcyZjk4OGJmLTg2ZjEtNCFhZi05MWFiLTJkN2NkMDExZGI0Nw"
        },
        {
          "displayName": "Norman Paulk",
          "id": "df828ec3-71d8-6e69-9afd-e736c5b32145",
          "uniqueName": "Fabrikamfiber16@hotmail.com",
          "descriptor": "s2s.M2FjODRhZmIeYWIwNC00ZWM0LWEyZWItOGEyYWJmNGJlNDQ3QDcyZjk4OGJmLTg2ZjEtNDFhZi05MWFiLTJkN2NkMDExZGI0Nw"
        },
        {
          "displayName": "Chuck Reinhart",
          "id": "df828ec3-71d8-6e69-9afd-g736c5a32145",
          "uniqueName": "fabrikamfiber3@hotmail.com",
          "descriptor": "s2s.M2FjODRhZmItYWIwNC00SWG0LWEyZWItOGEyYWJmNGJlNDQ3QDcyZjk4OGJmLTg2ZjEtNDFhZi05MWFiLTJkN2NkMDExZGI0Nw"
        }
      ],
      "dependentFields": [],
      "referenceName": "System.ChangedBy",
      "name": "Changed By",
      "url": "https://dev.azure.com/fabrikam/_apis/wit/fields/System.ChangedBy"
    }
    

    更多信息在这里: https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/work%20item%20types%20field?view=azure-devops-rest-5.1

    【讨论】:

      猜你喜欢
      • 2019-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多