# 说明

创建自定义字段(需求及缺陷)

# url

https://api.tapd.cn/custom_field_configs

# 支持格式

JSON/XML(默认JSON格式)

# HTTP请求方式

POST

# 请求数限制

  • 不能超过自定义字段的最大个数
  • 选项个数不能超过 500

# 请求参数

字段名 必选 类型及范围 说明 特殊规则
workspace_id integer 项目ID
entry_type string 新增字段分类 story(需求) bug(缺陷)
name string 字段名称
type string 字段类型 select 单选下拉列表、text 单行文本框、checkbox 复选框 、radio 单选框 、textarea 多行文本框 、 user_chooser 人名输入框 、dateinput 日期 、datetime 时分类型 、float 数值型、integer 整型、 cascade_checkbox 级联复选、 cascade_radio 级联单选
memo string 字段备注
option string 字段值选项 详细使用说明见下面

# 请求参数 option 详细说明

  1. 字段类型为 select、 radio、 checkbox、 cascade_checkbox、cascade_radio 类型时为必填
  2. 字段类型为 select、 radio、 checkbox、时,选项参数格式如:AA|BB|CC 格式,使用“|”隔开
  3. 字段类型为 cascade_checkbox、cascade_radio 级联类型时,选项参数格式必须是 json 结构,name 属性表示选项名, children 表示子选项。示例:[{"name":"1 ","children":[{"name":"11","children":[{"name":"111"},{"name":"112"}]}]},{"name":" 2","children":[{"name":"21","children":[{"name":"211"},{"name":"212"}]}]}] ,展开如下:
[
    {
        "name": "1  ",
        "children": [
            {
                "name": "11",
                "children": [
                    {
                        "name": "111"
                    },
                    {
                        "name": "112"
                    }
                ]
            }
        ]
    },
    {
        "name": " 2",
        "children": [
            {
                "name": "21",
                "children": [
                    {
                        "name": "211"
                    },
                    {
                        "name": "212"
                    }
                ]
            }
        ]
    }
]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

# 调用示例及返回结果

# 创建需求自定义字段配置

# curl 使用 Basic Auth 鉴权调用示例

curl -u 'api_user:api_password' -d 'entry_type=story&name=add_field&type=text&workspace_id=10158231' 'https://api.tapd.cn/custom_field_configs'

#

# 返回结果

{
    "status": 1,
    "data": {
        "CustomFieldConfig": {
            "id": "1010158231215016293",
            "workspace_id": "10158231",
            "entry_type": "story",
            "custom_field": "custom_field_three",
            "type": "text",
            "name": "add_field",
            "options": null,
            "enabled": "1",
            "sort": null,
            "memo": ""
        }
    },
    "info": "success"
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

# 创建需求选类型checkbox自定义字段配置

# curl 使用 Basic Auth 鉴权调用示例

curl -u 'api_user:api_password' -d 'entry_type=story&name=add_field2&memo=add_field_detail&type=checkbox&option=item1|item2|item3&workspace_id=10158231' 'https://api.tapd.cn/custom_field_configs'

#

# 返回结果

{
    "status": 1,
    "data": {
        "CustomFieldConfig": {
            "id": "1010158231215016295",
            "workspace_id": "10158231",
            "entry_type": "story",
            "custom_field": "custom_field_four",
            "type": "checkbox",
            "name": "add_field2",
            "options": "{\"1\":\"item1\",\"2\":\"item2\",\"3\":\"item3\"}",
            "enabled": "1",
            "sort": null,
            "memo": "add_field_detail"
        }
    },
    "info": "success"
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

# 创建缺陷级联多选字段

# curl 使用 Basic Auth 鉴权调用示例

curl -u 'api_user:api_password' -d 'workspace_id=51240826&entry_type=bug&option=%5B%7B%22name%22%3A%221%20%20%22%2C%22children%22%3A%5B%7B%22name%22%3A%2211%22%2C%22children%22%3A%5B%7B%22name%22%3A%22111%22%7D%2C%7B%22name%22%3A%22112%22%7D%5D%7D%5D%7D%2C%7B%22name%22%3A%22%202%22%2C%22children%22%3A%5B%7B%22name%22%3A%2221%22%2C%22children%22%3A%5B%7B%22name%22%3A%22211%22%7D%2C%7B%22name%22%3A%22212%22%7D%5D%7D%5D%7D%5D&type=cascade_checkbox&name=%E7%BC%BA%E9%99%B7%E7%BA%A7%E8%81%94tt' 'https://api.tapd.cn/custom_field_configs'

#

# 返回结果

{
    "status": 1,
    "data": {
        "CustomFieldConfig": {
            "id": "1151240826001007121",
            "workspace_id": "51240826",
            "entry_type": "bug",
            "custom_field": "custom_field_three",
            "type": "cascade_checkbox",
            "name": "缺陷级联tt",
            "options": "[{\"name\":\"1\",\"children\":[{\"name\":\"11\",\"children\":[{\"name\":\"111\"},{\"name\":\"112\"}]}]},{\"name\":\"2\",\"children\":[{\"name\":\"21\",\"children\":[{\"name\":\"211\"},{\"name\":\"212\"}]}]}]",
            "extra_config": null,
            "enabled": "1",
            "sort": "3",
            "memo": null
        }
    },
    "info": "success"
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

# 返回字段说明

字段 说明
id 自定义字段配置的ID
workspace_id 所属项目ID
entry_type 所属实体对象(story 、bug)
name 自定义字段名称
type 输入字段类型
created_from 请求来源
enabled 是否启用
memo 自定义字段显示备注
custom_field 自定义字段预留个数名称
options 自定义字段可选值
enabled 是否启用
sort 显示时排序系数
上次更新: 2023-07-14 16:56:45