專案

一般

個人檔案

動作

Wiki 頁面

取得 Wiki 頁面的清單

GET /projects/foo/wiki/index.xml

返回專案 Wiki 中所有頁面的清單。

回應:

<?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>

取得 Wiki 頁面

GET /projects/foo/wiki/UsersGuide.xml

返回 Wiki 頁面的詳細資訊。

可包含:
  • 附件

回應:

<?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>

取得 Wiki 頁面的舊版本

GET /projects/foo/wiki/UsersGuide/23.xml

返回 Wiki 頁面舊版本的詳細資訊。

可包含:
  • 附件

回應:

同上。

建立或更新 Wiki 頁面

PUT /projects/foo/wiki/UsersGuide.xml
<?xml version="1.0"?>
<wiki_page>
  <text>Example</text>
  <comments>Typo</comments>
</wiki_page>

建立或更新 Wiki 頁面。

更新現有頁面時,您可以包含一個 `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 Conflict` 錯誤。

附加檔案

JSON 範例

首先,上傳您的檔案

POST /uploads.json
Content-Type: application/octet-stream
...
(request body is the file content)

# 201 response
{"upload":{"token":"7167.ed1ccdb093229ca1bd0b043618d88743"}}

如果您想附加多個檔案,請逐一上傳,並儲存所有權杖。
然後使用附件權杖建立/更新 Wiki 頁面(以物件陣列的形式提供一個或多個檔案)

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"}
        ]
    }
}

注意事項

建立或更新 Wiki 頁面時,必須提供文字欄位,否則您將收到 `422 Unprocessable Entity` 錯誤,提示:「文字欄位不能為空白」。
如果您不想更改文字,可以先按照上述說明取得 Wiki 頁面,並在更新中提供當前的文字來保留它。

回應:
  • `204 No Content`:頁面已更新
  • `201 Created`:頁面已建立
  • `409 Conflict`:嘗試更新過時的頁面時發生(見上文)
  • `422 Unprocessable Entity`:頁面因驗證失敗而未儲存(回應主體包含錯誤訊息)

刪除 Wiki 頁面

DELETE /projects/foo/wiki/UsersGuide.xml

刪除 Wiki 頁面及其附件和歷史記錄。如果刪除的頁面是父頁面,則不會刪除其子頁面,而是將其更改為根頁面。

回應:
  • `204 No Content`:頁面已刪除

Go MAEDA將近 3 年前 更新 · 7 個版本