# 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" 
```