6
votes

I need to get the list of allowed values in a field (that aren't in a global list) using the TFS 2015 REST API for a particular work item type. I know that I can get information about a field with Get a work item field but that doesn't seem to give me the allowed values in the response.

{
  "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"
}

It looks like someone on the MSDN forums posted this back in June, but I want to double-check if this is still something that isn't yet available.

2

2 Answers

4
votes

REST API still doesn't support get allowedvalues in a field. There is already a UserVoice for this feature at website below, you can vote it:

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

Currently, you can only use old .net API to get allowedvalues by getting an instance of class FieldDefinition and referencing the AllowedValues property.

1
votes

As I understand, this is now supported since version 4.1

You can get the list of allowed values for a given field(s) in the context of a workitem.

A sample response is as follows:

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

More information here: https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/work%20item%20types%20field?view=azure-devops-rest-5.1