本文介绍了Azure DevOps REST API-选项列表如何与字段相关联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用rest创建字段和选择列表,在网站上,我创建了一个字段,类型为picklist String,并向列表中添加了一些项目:

I am trying to use rest to create fields and picklists, on the web site I created a field as type picklist String and added some items to the list:

字段的其他网址: https://dev.azure.com/ {org}/_ apis/work/processes/{processId}/workitemtypes/CMMI2.Bug/fields/Custom.AppType?api-version=5.0-preview.2

Rest url for field:https://dev.azure.com/{org}/_apis/work/processes/{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"
}

选项列表的其他URL: https://dev.azure.com/ {org}/_ apis/work/processes/lists/{picklistId}?api-version = 5.0-preview.1这将返回:

Rest URL for picklist:https://dev.azure.com/{org}/_apis/work/processes/lists/{picklistId}?api-version=5.0-preview.1this returns:

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

这里是有关此文档: https://docs.microsoft.com/zh-cn/rest/api/azure/devops/processes/fields/get?view=azure-devops-rest-5.0#processworkitemtypefield

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

Firstly - why is type of field string when it should be picklistString (as per documentation link)?

第二-选择列表如何链接到该字段?

Secondly - how is the picklist linked to the field?

谢谢

推荐答案

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

The picklistString refers to the name of the type, its actual property is string, so the field type it displays in type is string.

(1)为此,可以使用此 API :

(1) To achieve this, you can use this API:

POST  https://dev.azure.com/{organizationName}/{projectName}/_apis/wit/fields?api-version=5.1-preview.2

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

Here is my request body for you reference:

{
  "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 ,然后可以将选择列表链接到此新字段.

Note: Set isPicklist as true, and you can link picklist to this new field.

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

(2) For UI operation, just add new field, open the drop-down list of type and select picklist(string)/picklist(Integer) as what you need.

picklist(string) picklist(Integer)之间的区别在于 picklist(string)允许选择短文本字符串(255个字符或更少)的值,而 picklist(Integer)包含一个Integer值的选择列表.

The difference between picklist(string) and picklist(Integer) is that picklist(string) allow a pick list of short text string (255 characters or less) values, and picklist(Integer) contains a pick list of Integer values.

这篇关于Azure DevOps REST API-选项列表如何与字段相关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 03:35