{{< details >}}

  • Tier: 专业版, 旗舰版
  • Offering: JihuLab.com, 私有化部署

{{< /details >}}

群组 wiki API 仅在 APIv4 中可用。也可以使用项目 wiki的 API。

列出 wiki 页面

列出给定群组的所有 wiki 页面。

GET /groups/:id/wikis
属性 类型 必需 描述
id integer/string Yes 群组的 ID 或URL 编码路径
with_content boolean No 包含页面内容。
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/1/wikis?with_content=1"

示例响应:

[
  {
    "content" : "Here is an instruction how to deploy this project.",
    "format" : "markdown",
    "slug" : "deploy",
    "title" : "deploy",
    "encoding": "UTF-8"
  },
  {
    "content" : "Our development process is described here.",
    "format" : "markdown",
    "slug" : "development",
    "title" : "development",
    "encoding": "UTF-8"
  },{
    "content" : "*  [Deploy](deploy)\n*  [Development](development)",
    "format" : "markdown",
    "slug" : "home",
    "title" : "home",
    "encoding": "UTF-8"
  }
]

获取 wiki 页面

获取给定群组的 wiki 页面。

GET /groups/:id/wikis/:slug
属性 类型 必需 描述
id integer/string Yes 群组的 ID 或URL 编码路径
slug string Yes wiki 页面的 URL 编码 slug(唯一字符串),例如 dir%2Fpage_name
render_html boolean No 返回 wiki 页面的渲染 HTML。
version string No wiki 页面版本 SHA。
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/1/wikis/home"

示例响应:

{
  "content" : "home page",
  "format" : "markdown",
  "slug" : "home",
  "title" : "home",
  "encoding": "UTF-8"
}

创建新的 wiki 页面

使用给定的标题、slug 和内容为给定的仓库创建新的 wiki 页面。

POST /projects/:id/wikis
属性 类型 必需 描述
id integer/string Yes 群组的 ID 或URL 编码路径
content string Yes wiki 页面的内容。
title string Yes wiki 页面的标题。
format string No wiki 页面的格式。可用格式包括:markdown(默认)、rdocasciidocorg
curl --data "format=rdoc&title=Hello&content=Hello world" \
     --header "PRIVATE-TOKEN: <your_access_token>" \
     "https://gitlab.example.com/api/v4/groups/1/wikis"

示例响应:

{
  "content" : "Hello world",
  "format" : "markdown",
  "slug" : "Hello",
  "title" : "Hello",
  "encoding": "UTF-8"
}

编辑现有 wiki 页面

更新现有 wiki 页面。至少需要一个参数来更新 wiki 页面。

PUT /groups/:id/wikis/:slug
属性 类型 必需 描述
id integer/string Yes 群组的 ID 或URL 编码路径
content string Yes, 如果没有提供 title wiki 页面的内容。
title string Yes, 如果没有提供 content wiki 页面的标题。
format string No wiki 页面的格式。可用格式包括 markdown(默认)、rdocasciidocorg
slug string Yes wiki 页面的 URL 编码 slug(唯一字符串)。例如:dir%2Fpage_name
curl --request PUT --data "format=rdoc&content=documentation&title=Docs" \
     --header "PRIVATE-TOKEN: <your_access_token>" \
     "https://gitlab.example.com/api/v4/groups/1/wikis/foo"

示例响应:

{
  "content" : "documentation",
  "format" : "markdown",
  "slug" : "Docs",
  "title" : "Docs",
  "encoding": "UTF-8"
}

删除 wiki 页面

删除具有给定 slug 的 wiki 页面。

DELETE /groups/:id/wikis/:slug
属性 类型 必需 描述
id integer/string Yes 群组的 ID 或URL 编码路径
slug string Yes wiki 页面的 URL 编码 slug(唯一字符串),例如 dir%2Fpage_name
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/1/wikis/foo"

如果成功,预计会返回一个带有空体的 204 No Content HTTP 响应。

上传附件到 wiki 仓库

将文件上传到 wiki 仓库内的附件文件夹。附件文件夹是 uploads 文件夹。

POST /groups/:id/wikis/attachments
属性 类型 必需 描述
id integer/string Yes 群组的 ID 或URL 编码路径
file string Yes 要上传的附件。
branch string No 分支的名称。默认为 wiki 仓库默认分支。

要从文件系统上传文件,请使用 --form 参数。这会导致 cURL 使用头 Content-Type: multipart/form-data 发布数据。file= 参数必须指向文件系统上的文件,并以 @ 开头。例如:

curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" \
     --form "file=@dk.png" "https://gitlab.example.com/api/v4/groups/1/wikis/attachments"

示例响应:

{
  "file_name" : "dk.png",
  "file_path" : "uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png",
  "branch" : "main",
  "link" : {
    "url" : "uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png",
    "markdown" : "![dk](uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png)"
  }
}