Questions 社区问题接口

JSON 格式

NameTypeRead-onlyComment
idintegeryes文档分类id,由系统自动分配
urlstringyes资源url
topic_idintegerno该社区问题所属的社区话题
titlestringno社区问题名称
contentstringno社区问题描述
author_idintegerno社区问题创建者
created_atdateyes创建时间
updated_atdateyes最后更新时间

JSON 示例

{
  "id": 7,
  "url": "https://support.kf5.com/apiv2/questions/7.json",
  "topic_id": 6,
  "title": "问题标题",
  "content": "问题内容",
  "author_id": 748,
  "created_at": "2012-08-10 14:50:13",
  "updated_at": "2012-08-10 14:50:13"
}

社区问题列表

GET /apiv2/questions.json GET /apiv2/topics/{topic_id}/questions.json GET /apiv2/users/{user_id}/questions.json
调用权限

all users

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

{
  "questions": [
    {
      "id":   7,
      "title": "问题标题",
      ...
    },
    {
      "id":   425,
      "title": "问题反馈",
      ...
    }
  ]
}

查看社区问题

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

all users

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

{
  "question": {
   	  "id":   7,
      "title": "问题标题",
      ...
   }
}

创建社区问题

POST /apiv2/questions.json
调用权限

all users

curl 示例
curl https://{subdomain}.kf5.com/apiv2/questions.json 
  -H "Content-Type: application/json" -d '{"question": {"title": "this is question title","content": "this is content"}}' \
  -v -u {email_address}:{password} -X POST
返回示例
Status: 200 OK
Location: https://{subdomain}.kf5.com/apiv2/questions/{id}.json

{
  "question": {
      "id":   1233,
      "title": "this is question title",
      ...
   }
}

修改社区问题

PUT /apiv2/questions/{id}.json
调用权限

admin

curl 示例
curl https://{subdomain}.kf5.com/apiv2/questions/{id}.json 
  -H "Content-Type: application/json" -d '{"question": {"title": "this is new title"}}' 
  -v -u {email_address}:{password} -X PUT
返回示例
Status: 200 OK

{
  "question": {
      "id":   2014,
      "title": "this is new title",
      ...
   }
}

删除社区问题

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

admin

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

社区问题回复列表

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

all users

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

{
  "question_comments": [
    {
       "id": 103,
       "content": "问题解决了,谢谢!",
       ...
    },
    {
       "id": 102,
       "content": "this is comment's content",
       ...
    },
    ...    
   ]
}

查看指定社区问题回复

GET /apiv2/questions/{question_id}/comments/{id}.json
调用权限

end user

curl 示例
curl https://{subdomain}.kf5.com/apiv2/questions/{question_id}/comments/{id}.json \
  -v -u {email_address}/token:{api_token}
返回示例
Status: 200 OK

{
  "question_comment": 
    {
       "id": 103,
       "content": "问题解决了,谢谢!",
       ...
    }    
}

回复社区问题

PUT /apiv2/questions/{id}/comments.json
调用权限

end user

curl 示例
curl https://{subdomain}.kf5.com/apiv2/questions/{id}/comments.json \
  -d '{"request": {"comment": {"content": "Thanks!"}}}' \
  -v -u {email_address}/token:{api_token} -X PUT -H "Content-Type: application/json"
返回示例
Status: 201 Created

{
  "question_comment":
   {
      "id": 104,
      content": "Thanks!",
      ...
  }
}