创建分类接口[单条]

  • 接口说明: 创建分类接口[单条]
  • 接口地址: /api/categories
  • 请求方式: POST

请求参数

参数名称类型是否必须描述
namestring分类名称
descriptionstring分类说明
iconstring分类图标 URL[可通过上传图片接口上传图标]
sortint显示顺序
propertyint属性:0:正常 1:首页展示

请求示例

  1. {
  2. "data": {
  3. "type": "categories",
  4. "attributes": {
  5. "name": "{{$randomWord}}",
  6. "description": "{{$randomWords}}",
  7. "sort": "{{$randomInt}}",
  8. "icon": "{{$randomAvatarImage}}"
  9. }
  10. }
  11. }

返回说明

  • 成功,http 状态码 201
  • 失败,http 状态码 500

返回结果

参数名称类型出现要求描述
dataobject基础数据
typestring数据类型
idint数据 id
attributesobject数据属性
attributes.idint分类 id
attributes.namestring分类名称
attributes.iconstring分类图标 URL
attributes.descriptionstring分类说明
attributes.propertyint属性:0:正常 1:首页展示
attributes.sortint显示顺序
attributes.threadCountint主题总数

返回示例

  1. {
  2. "data": {
  3. "type": "categories",
  4. "id": "4",
  5. "attributes": {
  6. "name": "Latvia",
  7. "description": "iterate Agent",
  8. "icon": "",
  9. "sort": "63",
  10. "property": null,
  11. "thread_count": 0,
  12. "ip": "127.0.0.1",
  13. "created_at": "2019-12-02T18:08:17+08:00",
  14. "updated_at": "2019-12-02T18:08:17+08:00"
  15. }
  16. }
  17. }