2
votes

I'm trying to replicate an Azure DevOps process from one organization to another via the AZDO REST Api. I'm working on replicating the layout and am stuck because I can't discover the relationship between a custom field and a picklist when querying the source AZDO instance.

In my scenario I have a test work item type which I've called Issue. On the Issue interface I've created a custom field which is a picklist. While I can retrieve a list of lists via the Rest API and examine the field as well, I can't figure out how the two are related.

Here is a partial payload from the field:

{
    "count": 39,
    "value": [
...
        {
            "referenceName": "Custom.IssueSource",
            "name": "Issue Source",
            "type": "string",
            "description": "Who is this attributed to",
            "required": true,
            "url": "https://dev.azure.com/MYORG/_apis/work/processes/f390103e-7097-4f19-b5b5-f9dbcf92bb6f/behaviors",
            "customization": "custom"
        },
...   ]
}

and here is a partial payload from the lists get query which I used trial and error to determine was the picklist I've assigned:

{
    "count": 10,
    "value": [
...
        {
            "id": "2998d4e4-2bec-4935-98a1-b67a0b0b6d5d",
            "name": "picklist_e854661e-8620-4ad9-be28-b974c5cb3a5d",
            "type": "String",
            "isSuggested": false,
            "url": "https://dev.azure.com/MYORG/_apis/work/processes/lists/2998d4e4-2bec-4935-98a1-b67a0b0b6d5d"
        },
 ...
 ]
}

Here is a partial layout response for the WIT:

{
    "pages": [
        {
            "id": "d0171d51-ff84-4038-afc1-8800ab613160.System.WorkItemType.Details",
            "inherited": true,
            "label": "Details",
            "pageType": "custom",
            "visible": true,
            "isContribution": false,
            "sections": [
                {
                    "id": "Section1",
                    "groups": [
...
                        {
                            "id": "bf03e049-5062-4d82-b91d-4396541fbed2",
                            "label": "Custom",
                            "isContribution": false,
                            "visible": true,
                            "controls": [
                                {
                                    "id": "Custom.IssueSource",
                                    "label": "Issue Source",
                                    "controlType": "FieldControl",
                                    "readOnly": false,
                                    "visible": true,
                                    "isContribution": false
                                }
                            ]
                        }
                    ]
                },
...    ]
}

Using fiddler against the AZDO web interface, the only time I see a reference to the picklist is from another non-AZDO API to https://dev.azure.com/MYORG/_apis/Contribution/dataProviders/query

Is there a way to discover the link via the AZDO Rest API? I saw this question which was similar but was about creating the link

1

1 Answers

2
votes

Figured it out. Turns out you need to query from a different scope - work item tracking rather than work item tracking process:

https://dev.azure.com/MYORG/_apis/wit/fields/Custom.IssueSource?api-version=5.0-preview.2

returns

{
    "name": "Issue Source",
    "referenceName": "Custom.IssueSource",
    "description": "Who is this attributed to",
    "type": "string",
    "usage": "workItem",
    "readOnly": false,
    "canSortBy": true,
    "isQueryable": true,
     ...
    "isIdentity": false,
--> "isPicklist": true,
    "isPicklistSuggested": false,
--> "picklistId": "2998d4e4-2bec-4935-98a1-b67a0b0b6d5d",
    "url": "https://dev.azure.com/MYORG/_apis/wit/fields/Custom.IssueSource"
}