User Fields 用户自定义字段接口

JSON格式

NameTypeRead-onlyComment
idintegeryes用户字段id,由系统自动分配
urlstringyes当前资源url
namestringyes用户字段的名称,格式为"field_{id}"
typestringno字段类型
agent_titlestringno字段的显示名称
enduser_descriptionstringno字段的显示说明
activebooleanno字段是否启用
custom_field_optionsarrayno下拉菜单字段的选项数组

JSON 示例

{
  "id": 5,
  "url": "https://support.kf5.com/apiv2/user_fields/5.json",
  "name": "field_5",
  "type": "dropdownlist",
  "title": "性别",
  "description": "仅支持男,女",
  "active": true,
  "custom_field_options": [
  {
    "key": "男",
    "value": "男"
  },
  {
    "key": "女",
    "value": "女"
  }
  ]
}

用户自定义字段列表

GET /apiv2/user_fields.json
调用权限

agents

也可以使用如下API:

获取状态为启用的自定义字段列表
GET /apiv2/user_fields/active.json
curl 示例
curl https://{subdomain}.kf5.com/apiv2/user_fields.json \
  -v -u {email_address}:{password}
返回示例
Status: 200 OK

{
  "user_fields":[
   {
    "id": 5,
    "url": "https://support.kf5.com/apiv2/user_fields/5.json",
    "name": "field_5",
    "type": "dropdownlist",
    "title": "性别",
    "description": "仅支持男,女",
    "active": true,
    "custom_field_options": [
     {
      "key": "男",
      "value": "男"
     },
     {
      "key": "女",
      "value": "女"
     }
    ]
   }
  ]
}

查看用户自定义字段

GET /apiv2/user_fields/{id}.json
调用权限

agents

curl 示例
curl https://{subdomain}.kf5.com/apiv2/user_fields/{id}.json \
  -v -u {email_address}:{password}
返回示例
Status: 200 OK

{
  "user_fields":{
    "id": 5,
    "url": "https://support.kf5.com/apiv2/user_fields/5.json",
    "name": "field_5",
    "type": "dropdownlist",
    "title": "性别",
    "description": "仅支持男,女",
    "active": true,
    "custom_field_options": [
     {
      "key": "男",
      "value": "男"
     },
     {
      "key": "女",
      "value": "女"
     }
    ]
   }
}

删除用户自定义字段

DELETE /apiv2/user_fields/{id}.json
调用权限

admin

curl 示例
curl https://{subdomain}.kf5.com/apiv2/user_fields/{id}.json \
  -v -u {email_address}:{password} -X DELETE
返回示例
Status: 200 OK