Wikis API
- List wiki pages
 - Get a wiki page
 - Create a new wiki page
 - Edit an existing wiki page
 - Delete a wiki page
 - Upload an attachment to the wiki repository
 
Wikis API
在 GitLab 10.0 中引入 .
仅在 APIv4 中可用.
List wiki pages
获取给定项目的所有 Wiki 页面.
GET /projects/:id/wikis 
| Attribute | Type | Required | Description | 
|---|---|---|---|
 id  | 
integer/string | yes | 项目的 ID 或URL 编码的路径 | 
 with_content  | 
boolean | no | 包含页面内容 | 
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/wikis?with_content=1" 
响应示例:
[  {  "content"  :  "Here is an instruction how to deploy this project.",  "format"  :  "markdown",  "slug"  :  "deploy",  "title"  :  "deploy"  },  {  "content"  :  "Our development process is described here.",  "format"  :  "markdown",  "slug"  :  "development",  "title"  :  "development"  },{  "content"  :  "*  [Deploy](deploy)\n*  [Development](development)",  "format"  :  "markdown",  "slug"  :  "home",  "title"  :  "home"  }  ] 
Get a wiki page
获取给定项目的 Wiki 页面.
GET /projects/:id/wikis/:slug 
| Attribute | Type | Required | Description | 
|---|---|---|---|
 id  | 
integer/string | yes | 项目的 ID 或URL 编码的路径 | 
 slug  | 
string | yes | Wiki 页面的段(唯一字符串) | 
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/wikis/home" 
响应示例:
{  "content"  :  "home page",  "format"  :  "markdown",  "slug"  :  "home",  "title"  :  "home"  } 
Create a new wiki page
使用给定的标题,条目和内容为给定的存储库创建一个新的 Wiki 页面.
POST /projects/:id/wikis 
| Attribute | Type | Required | Description | 
|---|---|---|---|
 id  | 
integer/string | yes | 项目的 ID 或URL 编码的路径 | 
 content  | 
string | yes | Wiki 页面的内容 | 
 title  | 
string | yes | 维基页面的标题 | 
 format  | 
string | no |  Wiki 页面的格式. 可用格式为: markdown (默认), rdoc , asciidoc和org | 
curl --data "format=rdoc&title=Hello&content=Hello world" --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/wikis" 
响应示例:
{  "content"  :  "Hello world",  "format"  :  "markdown",  "slug"  :  "Hello",  "title"  :  "Hello"  } 
Edit an existing wiki page
更新现有的 Wiki 页面. 至少需要一个参数才能更新 Wiki 页面.
PUT /projects/:id/wikis/:slug 
| Attribute | Type | Required | Description | 
|---|---|---|---|
 id  | 
integer/string | yes | 项目的 ID 或URL 编码的路径 | 
 content  | 
string |  是,如果未提供title  | 
Wiki 页面的内容 | 
 title  | 
string |  是,如果未提供content  | 
维基页面的标题 | 
 format  | 
string | no |  Wiki 页面的格式. 可用格式为: markdown (默认), rdoc , asciidoc和org  | 
 slug  | 
string | yes | Wiki 页面的段(唯一字符串) | 
curl --request PUT --data "format=rdoc&content=documentation&title=Docs" --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/wikis/foo" 
响应示例:
{  "content"  :  "documentation",  "format"  :  "markdown",  "slug"  :  "Docs",  "title"  :  "Docs"  } 
Delete a wiki page
删除带有给定子弹的 Wiki 页面.
DELETE /projects/:id/wikis/:slug 
| Attribute | Type | Required | Description | 
|---|---|---|---|
 id  | 
integer/string | yes | 项目的 ID 或URL 编码的路径 | 
 slug  | 
string | yes | Wiki 页面的段(唯一字符串) | 
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/1/wikis/foo" 
成功时,HTTP 状态代码为204并且不需要 JSON 响应.
Upload an attachment to the wiki repository
将文件上传到 Wiki 信息库中的附件文件夹. 附件文件夹是uploads文件夹.
POST /projects/:id/wikis/attachments 
| Attribute | Type | Required | Description | 
|---|---|---|---|
 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/projects/1/wikis/attachments" 
响应示例:
{  "file_name"  :  "dk.png",  "file_path"  :  "uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png",  "branch"  :  "master",  "link"  :  {  "url"  :  "uploads/6a061c4cf9f1c28cb22c384b4b8d4e3c/dk.png",  "markdown"  :  ""  }  }