Azure DevOps REST API-挑选列表如何与字段关联?

Azure DevOps REST API-挑选列表如何与字段关联?,rest,azure-devops,Rest,Azure Devops,我正在尝试使用rest创建字段和选择列表,在网站上,我创建了一个字段作为类型选择列表字符串,并向列表中添加了一些项目: 字段的Rest url: {org}/_api/work/processs/{processId}/workitemtypes/CMMI2.Bug/fields/Custom.AppType?api version=5.0-preview.2 它返回的是: { referenceName: "Custom.AppType", name: "AppType", type: "s

我正在尝试使用rest创建字段和选择列表,在网站上,我创建了一个字段作为类型选择列表字符串,并向列表中添加了一些项目:

字段的Rest url: {org}/_api/work/processs/{processId}/workitemtypes/CMMI2.Bug/fields/Custom.AppType?api version=5.0-preview.2

它返回的是:

{
referenceName: "Custom.AppType",
name: "AppType",
type: "string",
description: "",
url: "https://dev.azure.com/{org}/_apis/work/processes/bd96307e-3d16-44ac-b498-be1a8daff2d5/behaviors",
customization: "custom"
}
选择列表的Rest URL: {org}/_api/work/processs/list/{picklistId}?api版本=5.0-preview.1 这将返回:

{
items: [
"All",
"Item2",
"Item3"
],
id: "{picklistId}",
name: "picklist_{diffGuidFromPickListId}",
type: "String",
isSuggested: false,
url: "https://dev.azure.com/{org}/_apis/work/processes/lists/{picklistId}"
}
以下是相关文档:

首先-为什么字段字符串的类型应该是picklistString(根据文档链接)

第二,选择列表如何链接到字段


感谢

picklistString引用类型的名称,它的实际属性是string,因此它在type中显示的字段类型是string

第二,选择列表如何链接到字段

(1) 要实现这一点,您可以使用以下方法:

以下是我的请求正文供您参考:

{
  "name": "{FieldName}",
  "referenceName": "{the reference name of WIT},
  "type": "string",
  "usage": "workItem",
  "readOnly": false,
  "canSortBy": true,
  "isQueryable": true,
  "supportedOperations": [
    {
      "referenceName": "{the reference name of WIT}"
      "name": "="
    }
  ],
  "isIdentity": true,
  "isPicklist": true,
  "isPicklistSuggested": false,
  "url": null
}
注意:将isPicklist设置为
true
,您可以将选取列表链接到此新字段

(2) 对于UI操作,只需添加新字段,打开类型的下拉列表,然后根据需要选择picklist(string)/picklist(Integer)


picklist(string)
picklist(Integer)
之间的区别在于。

这似乎都是毫无意义的,因为
picklistId
属性一旦设置好(即在字段创建时)就无法更改


在本参考资料中,
picklistId
的“可以更改”列的值为“否”:

谢谢您的回复。如何将字段与UI中的现有选取列表关联?哦,对不起。经过进一步的研究和与同事的讨论,我得到了一个解决方案。请尝试使用我的更新答案查看它是否可以帮助您将选择列表链接到字段。感谢您的回复,但我有点困惑,我在您的请求正文中没有看到您如何将字段与选择列表关联?或者将项目添加到该字段的选择列表中?我认为您还需要指定picklist id??如何使用VssConnection.GetClient管理此api?文件名在正文中指定,文件和picklist通过isPicklist:true连接。
{
  "name": "{FieldName}",
  "referenceName": "{the reference name of WIT},
  "type": "string",
  "usage": "workItem",
  "readOnly": false,
  "canSortBy": true,
  "isQueryable": true,
  "supportedOperations": [
    {
      "referenceName": "{the reference name of WIT}"
      "name": "="
    }
  ],
  "isIdentity": true,
  "isPicklist": true,
  "isPicklistSuggested": false,
  "url": null
}