【问题标题】:Azure DevOps API - how to discover link between field and picklistAzure DevOps API - 如何发现字段和选项列表之间的链接
【发布时间】:2020-06-06 11:31:49
【问题描述】:

我正在尝试通过 AZDO REST Api 将 Azure DevOps 流程从一个组织复制到另一个组织。我正在复制布局,但由于在查询源 AZDO 实例时无法发现自定义字段和选项列表之间的关系,所以我卡住了。

在我的场景中,我有一个称为问题的测试工作项类型。在问题界面上,我创建了一个自定义字段,它是一个选项列表。虽然我可以通过 Rest API retrieve a list of listsexamine the field 进行操作,但我无法弄清楚两者之间的关系。

这是部分有效载荷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"
        },
...   ]
}

这是来自lists get query 的部分有效负载,我通过反复试验确定是我分配的选项列表:

{
    "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"
        },
 ...
 ]
}

这是 WIT 的部分layout response

{
    "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
                                }
                            ]
                        }
                    ]
                },
...    ]
}

对 AZDO Web 界面使用提琴手,我唯一看到对选择列表的引用是从另一个非 AZDO API 到 https://dev.azure.com/MYORG/_apis/Contribution/dataProviders/query

有没有办法通过 AZDO Rest API 发现链接?我看到了this question which was similar but was about creating the link

【问题讨论】:

    标签: rest azure-devops


    【解决方案1】:

    想通了。原来你需要从不同的范围查询 - work item tracking 而不是 work item tracking process

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

    返回

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

    【讨论】:

    • 当我试图通过 API 更新自定义字段的选择列表但找不到两者之间的联系时,这让我一整天都感到困惑。现在我可以获取我的字段的 picklistId 并对其进行更新,谢谢!
    猜你喜欢
    • 2019-10-04
    • 2012-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-24
    • 2021-03-03
    • 1970-01-01
    相关资源
    最近更新 更多