341.md 17.4 KB
Newer Older
Lab机器人's avatar
readme  
Lab机器人 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
# Notes API

> 原文:[https://docs.gitlab.com/ee/api/notes.html](https://docs.gitlab.com/ee/api/notes.html)

*   [Notes pagination](#notes-pagination)
*   [Issues](#issues)
    *   [List project issue notes](#list-project-issue-notes)
    *   [Get single issue note](#get-single-issue-note)
    *   [Create new issue note](#create-new-issue-note)
    *   [Modify existing issue note](#modify-existing-issue-note)
    *   [Delete an issue note](#delete-an-issue-note)
*   [Snippets](#snippets)
    *   [List all snippet notes](#list-all-snippet-notes)
    *   [Get single snippet note](#get-single-snippet-note)
    *   [Create new snippet note](#create-new-snippet-note)
    *   [Modify existing snippet note](#modify-existing-snippet-note)
    *   [Delete a snippet note](#delete-a-snippet-note)
*   [Merge Requests](#merge-requests)
    *   [List all merge request notes](#list-all-merge-request-notes)
    *   [Get single merge request note](#get-single-merge-request-note)
    *   [Create new merge request note](#create-new-merge-request-note)
    *   [Modify existing merge request note](#modify-existing-merge-request-note)
    *   [Delete a merge request note](#delete-a-merge-request-note)
*   [Epics](#epics-ultimate)
    *   [List all epic notes](#list-all-epic-notes)
    *   [Get single epic note](#get-single-epic-note)
    *   [Create new epic note](#create-new-epic-note)
    *   [Modify existing epic note](#modify-existing-epic-note)
    *   [Delete an epic note](#delete-an-epic-note)

# Notes API[](#notes-api "Permalink")

注释是对以下内容的评论:

*   Snippets
*   Issues
*   合并要求
*   Epics

这包括系统注释,这些注释是有关对象更改的注释(例如,当里程碑更改时,将有相应的系统注释). 标签注释不是此 API 的一部分,而是在[资源标签事件中](resource_label_events.html)记录为单独的[事件](resource_label_events.html) .

## Notes pagination[](#notes-pagination "Permalink")

默认情况下,因为 API 结果是分页的,所以`GET`请求一次返回 20 个结果.

阅读有关[分页的](README.html#pagination)更多信息.

## Issues[](#issues "Permalink")

### List project issue notes[](#list-project-issue-notes "Permalink")

获取单个问题的所有注释的列表.

```
GET /projects/:id/issues/:issue_iid/notes
GET /projects/:id/issues/:issue_iid/notes?sort=asc&order_by=updated_at 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `issue_iid` | integer | yes | 问题的 IID |
| `sort` | string | no | 返回按`asc``desc`排列的发行说明. 默认为`desc` |
| `order_by` | string | no | 返回按`created_at``updated_at`字段排序的发行说明. 默认为`created_at` |

```
[  {  "id":  302,  "body":  "closed",  "attachment":  null,  "author":  {  "id":  1,  "username":  "pipin",  "email":  "admin@example.com",  "name":  "Pip",  "state":  "active",  "created_at":  "2013-09-30T13:46:01Z"  },  "created_at":  "2013-10-02T09:22:45Z",  "updated_at":  "2013-10-02T10:22:45Z",  "system":  true,  "noteable_id":  377,  "noteable_type":  "Issue",  "noteable_iid":  377,  "resolvable":  false,  "confidential":  false  },  {  "id":  305,  "body":  "Text of the comment\r\n",  "attachment":  null,  "author":  {  "id":  1,  "username":  "pipin",  "email":  "admin@example.com",  "name":  "Pip",  "state":  "active",  "created_at":  "2013-09-30T13:46:01Z"  },  "created_at":  "2013-10-02T09:56:03Z",  "updated_at":  "2013-10-02T09:56:03Z",  "system":  true,  "noteable_id":  121,  "noteable_type":  "Issue",  "noteable_iid":  121,  "resolvable":  false,  "confidential":  true  }  ] 
```

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/issues/11/notes" 
```

### Get single issue note[](#get-single-issue-note "Permalink")

返回有关特定项目问题的单个注释

```
GET /projects/:id/issues/:issue_iid/notes/:note_id 
```

Parameters:

*   `id` (必填)-项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding)
*   `issue_iid` (必填)-项目问题的 IID
*   `note_id` (必填)-问题注释的 ID

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/issues/11/notes/1" 
```

### Create new issue note[](#create-new-issue-note "Permalink")

为单个项目问题创建新的注释.

```
POST /projects/:id/issues/:issue_iid/notes 
```

Parameters:

*   `id` (必填)-项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding)
*   `issue_iid` (必填)-问题的 IID
*   `body` (必填)-注释的内容. 限制为 1,000,000 个字符.
*   `confidential` (可选)-便笺的机密标志. 默认为 false.
*   `created_at` (可选)-日期时间字符串,ISO 8601 格式,例如 2016-03-11T03:45:40Z(需要管理员或项目/组所有者权限)

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/issues/11/notes?body=note" 
```

### Modify existing issue note[](#modify-existing-issue-note "Permalink")

修改问题的现有注释.

```
PUT /projects/:id/issues/:issue_iid/notes/:note_id 
```

Parameters:

*   `id` (必填)-项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding)
*   `issue_iid` (必填)-问题的 IID
*   `note_id` (必填)-注释的 ID
*   `body` (必填)-注释的内容. 限制为 1,000,000 个字符.

```
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/issues/11/notes?body=note" 
```

### Delete an issue note[](#delete-an-issue-note "Permalink")

删除问题的现有注释.

```
DELETE /projects/:id/issues/:issue_iid/notes/:note_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `issue_iid` | integer | yes | 问题的 IID |
| `note_id` | integer | yes | 笔记的 ID |

```
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/issues/11/notes/636" 
```

## Snippets[](#snippets "Permalink")

### List all snippet notes[](#list-all-snippet-notes "Permalink")

获取单个代码段的所有注释的列表. 片段注释是用户可以发布到片段的注释.

```
GET /projects/:id/snippets/:snippet_id/notes
GET /projects/:id/snippets/:snippet_id/notes?sort=asc&order_by=updated_at 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `snippet_id` | integer | yes | 项目代码段的 ID |
| `sort` | string | no | 返回按`asc``desc`顺序排序的`asc`注释. 默认为`desc` |
| `order_by` | string | no | 返回按`created_at``updated_at`字段排序的`created_at`注释. 默认为`created_at` |

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippets/11/notes" 
```

### Get single snippet note[](#get-single-snippet-note "Permalink")

返回给定片段的单个音符.

```
GET /projects/:id/snippets/:snippet_id/notes/:note_id 
```

Parameters:

*   `id` (必填)-项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding)
*   `snippet_id` (必填)-项目代码段的 ID
*   `note_id` (必填)- `note_id`的 ID

```
{  "id":  52,  "title":  "Snippet",  "file_name":  "snippet.rb",  "author":  {  "id":  1,  "username":  "pipin",  "email":  "admin@example.com",  "name":  "Pip",  "state":  "active",  "created_at":  "2013-09-30T13:46:01Z"  },  "expires_at":  null,  "updated_at":  "2013-10-02T07:34:20Z",  "created_at":  "2013-10-02T07:34:20Z"  } 
```

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippets/11/notes/11" 
```

### Create new snippet note[](#create-new-snippet-note "Permalink")

为单个代码段创建新的音符. 片段注释是用户可以发布到片段的注释. 如果您在主体仅包含奖励表情符号的位置创建注释,则会收到该对象的回信.

```
POST /projects/:id/snippets/:snippet_id/notes 
```

Parameters:

*   `id` (必填)-项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding)
*   `snippet_id` (必填)-代码段的 ID
*   `body` (必填)-注释的内容. 限制为 1,000,000 个字符.
*   `created_at` (可选)-日期时间字符串,ISO 8601 格式,例如 2016-03-11T03:45:40Z

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippet/11/notes?body=note" 
```

### Modify existing snippet note[](#modify-existing-snippet-note "Permalink")

修改代码段的现有注释.

```
PUT /projects/:id/snippets/:snippet_id/notes/:note_id 
```

Parameters:

*   `id` (required) - The ID or [URL-encoded path of the project](README.html#namespaced-path-encoding)
*   `snippet_id` (必填)-代码段的 ID
*   `note_id` (必填)-注释的 ID
*   `body` (必填)-注释的内容. 限制为 1,000,000 个字符.

```
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippets/11/notes?body=note" 
```

### Delete a snippet note[](#delete-a-snippet-note "Permalink")

删除片段的现有注释.

```
DELETE /projects/:id/snippets/:snippet_id/notes/:note_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `snippet_id` | integer | yes | 片段的 ID |
| `note_id` | integer | yes | 笔记的 ID |

```
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippets/52/notes/1659" 
```

## Merge Requests[](#merge-requests "Permalink")

### List all merge request notes[](#list-all-merge-request-notes "Permalink")

获取单个合并请求的所有注释的列表.

```
GET /projects/:id/merge_requests/:merge_request_iid/notes
GET /projects/:id/merge_requests/:merge_request_iid/notes?sort=asc&order_by=updated_at 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `merge_request_iid` | integer | yes | 项目合并请求的 IID |
| `sort` | string | no | 返回以`asc``desc`顺序排序的合并请求注释. 默认为`desc` |
| `order_by` | string | no | 返回由`created_at``updated_at`字段排序的合并请求注释. 默认为`created_at` |

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/11/notes" 
```

### Get single merge request note[](#get-single-merge-request-note "Permalink")

返回给定合并请求的单个注释.

```
GET /projects/:id/merge_requests/:merge_request_iid/notes/:note_id 
```

Parameters:

*   `id` (必填)-项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding)
*   `merge_request_iid` (必填)-项目合并请求的 IID
*   `note_id` (必需)-合并请求注释的 ID

```
{  "id":  301,  "body":  "Comment for MR",  "attachment":  null,  "author":  {  "id":  1,  "username":  "pipin",  "email":  "admin@example.com",  "name":  "Pip",  "state":  "active",  "created_at":  "2013-09-30T13:46:01Z"  },  "created_at":  "2013-10-02T08:57:14Z",  "updated_at":  "2013-10-02T08:57:14Z",  "system":  false,  "noteable_id":  2,  "noteable_type":  "MergeRequest",  "noteable_iid":  2,  "resolvable":  false,  "confidential":  false  } 
```

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/11/notes/1" 
```

### Create new merge request note[](#create-new-merge-request-note "Permalink")

为单个合并请求创建一个新注释. 如果您在主体仅包含奖励表情符号的位置创建注释,则会收到该对象的回信.

```
POST /projects/:id/merge_requests/:merge_request_iid/notes 
```

Parameters:

*   `id` (必填)-项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding)
*   `merge_request_iid` (必填)-合并请求的 IID
*   `body` (必填)-注释的内容. 限制为 1,000,000 个字符.
*   `created_at` (可选)-日期时间字符串,ISO 8601 格式,例如 2016-03-11T03:45:40Z

### Modify existing merge request note[](#modify-existing-merge-request-note "Permalink")

修改合并请求的现有注释.

```
PUT /projects/:id/merge_requests/:merge_request_iid/notes/:note_id 
```

Parameters:

*   `id` (必填)-项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding)
*   `merge_request_iid` (必填)-合并请求的 IID
*   `note_id` (必填)-注释的 ID
*   `body` (必填)-注释的内容. 限制为 1,000,000 个字符.

```
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/11/notes?body=note" 
```

### Delete a merge request note[](#delete-a-merge-request-note "Permalink")

删除合并请求的现有注释.

```
DELETE /projects/:id/merge_requests/:merge_request_iid/notes/:note_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 项目的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `merge_request_iid` | integer | yes | 合并请求的 IID |
| `note_id` | integer | yes | 笔记的 ID |

```
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/merge_requests/7/notes/1602" 
```

## Epics[](#epics-ultimate "Permalink")

### List all epic notes[](#list-all-epic-notes "Permalink")

获取单个史诗的所有注释的列表. 史诗笔记是用户可以发布到史诗中的评论.

```
GET /groups/:id/epics/:epic_id/notes
GET /groups/:id/epics/:epic_id/notes?sort=asc&order_by=updated_at 
```

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 组的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `epic_id` | integer | yes | 小组史诗的 ID |
| `sort` | string | no | 返回按`asc``desc`排列的史诗笔记. 默认为`desc` |
| `order_by` | string | no | 返回按`created_at``updated_at`字段排序的史诗笔记. 默认为`created_at` |

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/epics/11/notes" 
```

### Get single epic note[](#get-single-epic-note "Permalink")

返回给定史诗的单个音符.

```
GET /groups/:id/epics/:epic_id/notes/:note_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 组的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `epic_id` | integer | yes | 史诗的 ID |
| `note_id` | integer | yes | 笔记的 ID |

```
{  "id":  52,  "title":  "Epic",  "file_name":  "epic.rb",  "author":  {  "id":  1,  "username":  "pipin",  "email":  "admin@example.com",  "name":  "Pip",  "state":  "active",  "created_at":  "2013-09-30T13:46:01Z"  },  "expires_at":  null,  "updated_at":  "2013-10-02T07:34:20Z",  "created_at":  "2013-10-02T07:34:20Z",  "confidential":  false  } 
```

```
curl --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/epics/11/notes/1" 
```

### Create new epic note[](#create-new-epic-note "Permalink")

为单个史诗创建新的音符. 史诗笔记是用户可以发布到史诗中的评论. 如果您在主体仅包含奖励表情符号的位置创建注释,则会收到该对象的回信.

```
POST /groups/:id/epics/:epic_id/notes 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 组的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `epic_id` | integer | yes | 史诗的 ID |
| `body` | string | yes | 注释的内容. 限制为 1,000,000 个字符. |

```
curl --request POST --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippet/11/notes?body=note" 
```

### Modify existing epic note[](#modify-existing-epic-note "Permalink")

修改史诗的现有注释.

```
PUT /groups/:id/epics/:epic_id/notes/:note_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 组的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `epic_id` | integer | yes | 史诗的 ID |
| `note_id` | integer | yes | 笔记的 ID |
| `body` | string | yes | 注释的内容. 限制为 1,000,000 个字符. |

```
curl --request PUT --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/projects/5/snippet/11/notes?body=note" 
```

### Delete an epic note[](#delete-an-epic-note "Permalink")

删除史诗的现有音符.

```
DELETE /groups/:id/epics/:epic_id/notes/:note_id 
```

Parameters:

| Attribute | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | integer/string | yes | 组的 ID 或[URL 编码的路径](README.html#namespaced-path-encoding) |
| `epic_id` | integer | yes | 史诗的 ID |
| `note_id` | integer | yes | 笔记的 ID |

```
curl --request DELETE --header "PRIVATE-TOKEN: <your_access_token>" "https://gitlab.example.com/api/v4/groups/5/epics/52/notes/1659" 
```