基本信息
接口名称: 更新栏目
接口类型: 数据更新
接口说明: 在某个站点内更新一个栏目
详细信息
URL
https://www.baklib.com/api/v1/channels/:id
完整URL示例
https://www.baklib.com/api/v1/channels/7e7f91a9-88ef-4084-9b7d-3a44cf9d7ec9
HTTP请求方式
PUT
授权认证方式
默认方式,需要添加请求header
Authorization: Bearer <token>
请求参数
参数 | 必选 | 类型及范围 | 说明 |
---|---|---|---|
tenant_id | true | String | 站点id |
name | String | 栏目标题 | |
description | String | 描述 | |
icon_name | String | 图标 | |
id | true | String | 栏目id |
示例代码
require 'faraday'
require 'json'
host = 'https://www.baklib.com/'
client = Faraday.new(url: host) do |conn|
conn.headers['Authorization'] = "Bearer #{token}"
conn.headers['Content-Type'] = 'application/json'
conn.adapter :net_http
end
params = {
tenant_id: "#{tenant_id}",
name: 'rails guide',
description: '本文介绍如何开始使用 Ruby on Rails。'
}
response = client.put("/api/v1/channels/#{channel_id}", params.to_json)
JSON.parse(response.body)
返回结果
{
"code": 0,
"status": "success",
"message": {
"id": "7e7f91a9-88ef-4084-9b7d-3a44cf9d7ec9",
"parent_id": null,
"name": "rails guide",
"identifier": "84b0",
"description": "本文介绍如何开始使用 Ruby on Rails。",
"content": {},
"ordinal": 0,
"features": {
"icon_name": "fa fa-folder-o",
"article_template": "article.default"
},
"status": 1,
"status_name": "发布",
"kind": 1,
"kind_name": "栏目",
"slug": "84b0",
"tenant_id": "682c1cf8-41bf-4417-aa05-3e682fb5174b",
"visits_count": 0,
"created_at": "2020-04-01T11:54:24.762+08:00",
"updated_at": "2020-04-01T16:13:33.910+08:00",
"created_by": "5b062111-13d7-41a2-9d2b-f3e0de23c98c",
"updated_by": "5b062111-13d7-41a2-9d2b-f3e0de23c98c",
"tag_list": []
}
}
返回字段说明
返回值字段 | 字段类型 | 说明 |
---|---|---|
code | Integer | 状态码 |
status | String | 返回状态 |
id | String | 栏目id |
parent_id | String | 父级栏目id |
name | String | 栏目标题 |
identifier | String | 栏目唯一标识符 |
status | Integer | 栏目状态 |
status_name | String | 栏目状态中文名称 |
tenant_id | String | 站点id |
created_at | Datetime | 创建时间 |
updated_at | Datetime | 更新时间 |
created_by | String | 创建者id |
updated_by | String | 更新者id |