操作
维基页面¶
获取维基页面列表¶
GET /projects/foo/wiki/index.xml
返回项目维基中所有页面的列表。
响应:
<?xml version="1.0"?>
<wiki_pages type="array">
<wiki_page>
<title>UsersGuide</title>
<version>2</version>
<created_on>2008-03-09T12:07:08Z</created_on>
<updated_on>2008-03-09T23:41:33+01:00</updated_on>
</wiki_page>
...
</wiki_pages>
获取维基页面¶
GET /projects/foo/wiki/UsersGuide.xml
返回维基页面的详细信息。
可包含:- 附件
响应:
<?xml version="1.0"?> <wiki_page> <title>UsersGuide</title> <parent title="Installation_Guide"/> <text>h1. Users Guide ... ...</text> <version>22</version> <author id="11" name="John Smith"/> <comments>Typo</comments> <created_on>2009-05-18T20:11:52Z</created_on> <updated_on>2012-10-02T11:38:18Z</updated_on> </wiki_page>
获取维基页面的旧版本¶
GET /projects/foo/wiki/UsersGuide/23.xml
返回维基页面旧版本的详细信息。
可包含:- 附件
响应:
与上面相同。
创建或更新维基页面¶
PUT /projects/foo/wiki/UsersGuide.xml <?xml version="1.0"?> <wiki_page> <text>Example</text> <comments>Typo</comments> </wiki_page>
创建或更新维基页面。
在更新现有页面时,您可以通过包含一个 version 属性来确保在尝试更新时页面是特定版本(例如,您不想覆盖您检索页面后所做的更新)。示例
PUT /projects/foo/wiki/UsersGuide.xml <?xml version="1.0"?> <wiki_page> <text>Example</text> <comments>Typo</comments> <version>18</version> </wiki_page>
如果页面当前版本为18,则这将更新页面,否则将返回 409 冲突 错误。
附件¶
JSON示例
首先,上传您的文件(s)
POST /uploads.json
Content-Type: application/octet-stream
...
(request body is the file content)
# 201 response
{"upload":{"token":"7167.ed1ccdb093229ca1bd0b043618d88743"}}
如果您要附加多个文件,请逐个上传它们,并保存所有令牌。
然后使用附件令牌(提供作为对象数组的文件)创建/更新维基页面
PUT /projects/project_name/wiki/wiki_name.json
{
"wiki_page": {
"text": "This is a wiki page with images (like this: !img.png!), and other files.",
"uploads": [
{"token": "7167.ed1ccdb093229ca1bd0b043618d88743", "filename": "img.bmp", "content-type": "image/png"},
{"token": "7168.d595398bbb104ed3bba0eed666785cc6", "filename": "document.pdf", "content-type": "application/pdf"}
]
}
}
注意
在创建或更新维基页面时,必须提供文本字段,否则您将收到一个 422 无法处理实体 错误,表明:“文本字段不能为空”。
如果您不想更改文本,您可以通过首先按照上述方法获取维基页面,并在更新中提供当前文本来保留它。
204 无内容:页面已更新201 已创建:页面已创建409 冲突:在尝试更新过时的页面时发生(见上面)422 无法处理实体:页面未保存,因为验证失败(响应正文中包含错误消息)
删除维基页面¶
DELETE /projects/foo/wiki/UsersGuide.xml
删除维基页面、其附件及其历史记录。如果删除的页面是父页面,则其子页面不会被删除,而是作为根页面更改。
响应:204 无内容:页面已删除