# Issues API > 原文:[https://docs.gitlab.com/ee/api/issues.html](https://docs.gitlab.com/ee/api/issues.html) * [Issues pagination](#issues-pagination) * [List issues](#list-issues) * [List group issues](#list-group-issues) * [List project issues](#list-project-issues) * [Single issue](#single-issue) * [New issue](#new-issue) * [Rate limits](#rate-limits) * [Edit issue](#edit-issue) * [Delete an issue](#delete-an-issue) * [Reorder an issue](#reorder-an-issue) * [Move an issue](#move-an-issue) * [Subscribe to an issue](#subscribe-to-an-issue) * [Unsubscribe from an issue](#unsubscribe-from-an-issue) * [Create a todo](#create-a-todo) * [Set a time estimate for an issue](#set-a-time-estimate-for-an-issue) * [Reset the time estimate for an issue](#reset-the-time-estimate-for-an-issue) * [Add spent time for an issue](#add-spent-time-for-an-issue) * [Reset spent time for an issue](#reset-spent-time-for-an-issue) * [Get time tracking stats](#get-time-tracking-stats) * [List merge requests related to issue](#list-merge-requests-related-to-issue) * [List merge requests that will close issue on merge](#list-merge-requests-that-will-close-issue-on-merge) * [Participants on issues](#participants-on-issues) * [Comments on issues](#comments-on-issues) * [Get user agent details](#get-user-agent-details) # Issues API[](#issues-api "Permalink") 如果用户不是项目成员,并且该项目是私有项目,则对该项目的`GET`请求将产生`404`状态代码. ## Issues pagination[](#issues-pagination "Permalink") 默认情况下,因为 API 结果是分页的,所以`GET`请求一次返回 20 个结果. 阅读有关[分页的](README.html#pagination)更多信息. **弃用:不建议使用**响应中的`reference`属性,而推荐使用`references` . >推出了[GitLab 12.6](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/20354)**注意:** > `references.relative`相对于正在请求问题的组/项目. 从其项目中获取问题时> `relative`格式将与`short`格式相同,并且在跨组/项目进行请求时, `relative`格式将与`full`格式相同. ## List issues[](#list-issues "Permalink") 获取经过身份验证的用户有权访问的所有问题. 默认情况下,它仅返回当前用户创建的问题. 要获取所有问题,请使用参数`scope=all` . ``` GET /issues GET /issues?state=opened GET /issues?state=closed GET /issues?labels=foo GET /issues?labels=foo,bar GET /issues?labels=foo,bar&state=opened GET /issues?milestone=1.0.0 GET /issues?milestone=1.0.0&state=opened GET /issues?iids[]=42&iids[]=43 GET /issues?author_id=5 GET /issues?assignee_id=5 GET /issues?my_reaction_emoji=star GET /issues?search=foo&in=title GET /issues?confidential=true ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `state` | string | no | 返回`all`问题,或者仅返回已`opened`或`closed` | | `labels` | string | no | Comma-separated list of label names, issues must have all labels to be returned. `None` lists all issues with no labels. `Any` lists all issues with at least one label. `No+Label` (Deprecated) lists all issues with no labels. Predefined names are case-insensitive. | | `with_labels_details` | boolean | no | 如果为`true` ,则响应将为标签字段中的每个标签返回更多详细信息`:name` , `:color` , `:description` , `:description_html` , `:text_color` . 默认值为`false` . [GitLab 12.7](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/21413)中引入了`description_html`属性 | | `milestone` | string | no | 里程碑标题. `None`列出没有里程碑的所有问题. `Any`列出具有指定里程碑的所有问题. | | `scope` | string | no | 回到问题在给定范围: `created_by_me` , `assigned_to_me`或`all` . 默认为`created_by_me` 对于 11.0 之前的版本,请改用现在不建议使用`created-by-me`范围或`created-by-me` `assigned-to-me`范围. *(在 GitLab 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13004) .在 GitLab 11.0 中[更改为 snake_case](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/18935) )* | | `author_id` | integer | no | 返回由给定用户`id`创建的问题. 与`author_username` . 与`scope=all`或`scope=assigned_to_me`结合使用. *(在 GitLab 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13004) )* | | `author_username` | string | no | 返回由给定`username`创建的问题. 类似于`author_id`并且与`author_id` . | | `assignee_id` | integer | no | 返回分配给给定用户`id` . 互斥与`assignee_username` . `None`返回未分配的问题. 受让人有`Any`退货问题. *(在 GitLab 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13004) )* | | `assignee_username` | 字符串数组 | no | 返回分配给给定`username` . 类似于`assignee_id`并且与`assignee_id`互斥. 在 GitLab CE 中, `assignee_username`数组应仅包含单个值,否则将返回无效的参数错误. | | `my_reaction_emoji` | string | no | 返回的问题由已验证的用户通过给定的`emoji`响应. `None`返回没有响应的问题. 至少有一个反应, `Any`回报问题. *(在 GitLab 10.0 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/14016) )* | | `weight` | integer | no | 以指定的`weight`返回问题. `None`返回没有分配权重的问题. 分配了权重的`Any`退货问题. | | `iids[]` | 整数数组 | no | 仅返回具有给定`iid`的问题 | | `order_by` | string | no | 回到问题下令`created_at` , `updated_at` , `priority` , `due_date` , `relative_position` , `label_priority` , `milestone_due` , `popularity` , `weight`领域. 默认为`created_at` | | `sort` | string | no | 返回按`asc`或`desc`排列的问题. 默认为`desc` | | `search` | string | no | 根据`title`和`description`搜索问题 | | `in` | string | no | 修改`search`属性的范围. `title` , `description`或以逗号将它们连接在一起的字符串. 默认为`title,description` | | `created_after` | datetime | no | 返回在给定时间或之后创建的问题 | | `created_before` | datetime | no | 返回在给定时间或之前创建的问题 | | `updated_after` | datetime | no | 返回在给定时间或之后更新的问题 | | `updated_before` | datetime | no | 返回在给定时间或之前更新的问题 | | `confidential` | boolean | no | 过滤机密或公共问题. | | `not` | Hash | no | 返回与提供的参数不匹配的问题. 接受: `labels` , `milestone` , `author_id` , `author_username` , `assignee_id` , `assignee_username` , `my_reaction_emoji` | | `non_archived` | boolean | no | 仅从未归档的项目返回问题. 如果为`false` ,则响应将返回已归档和未归档项目中的问题. 默认值为`true` . *(在[GitLab 13.0 中](https://gitlab.com/gitlab-org/gitlab/-/issues/197170)引入)* | ``` curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/issues" ``` 响应示例: ``` [ { "state" : "opened", "description" : "Ratione dolores corrupti mollitia soluta quia.", "author" : { "state" : "active", "id" : 18, "web_url" : "https://gitlab.example.com/eileen.lowe", "name" : "Alexandra Bashirian", "avatar_url" : null, "username" : "eileen.lowe" }, "milestone" : { "project_id" : 1, "description" : "Ducimus nam enim ex consequatur cumque ratione.", "state" : "closed", "due_date" : null, "iid" : 2, "created_at" : "2016-01-04T15:31:39.996Z", "title" : "v4.0", "id" : 17, "updated_at" : "2016-01-04T15:31:39.996Z" }, "project_id" : 1, "assignees" : [{ "state" : "active", "id" : 1, "name" : "Administrator", "web_url" : "https://gitlab.example.com/root", "avatar_url" : null, "username" : "root" }], "assignee" : { "state" : "active", "id" : 1, "name" : "Administrator", "web_url" : "https://gitlab.example.com/root", "avatar_url" : null, "username" : "root" }, "updated_at" : "2016-01-04T15:31:51.081Z", "closed_at" : null, "closed_by" : null, "id" : 76, "title" : "Consequatur vero maxime deserunt laboriosam est voluptas dolorem.", "created_at" : "2016-01-04T15:31:51.081Z", "moved_to_id" : null, "iid" : 6, "labels" : ["foo", "bar"], "upvotes": 4, "downvotes": 0, "merge_requests_count": 0, "user_notes_count": 1, "due_date": "2016-07-22", "web_url": "http://example.com/my-group/my-project/issues/6", "references": { "short": "#6", "relative": "my-group/my-project#6", "full": "my-group/my-project#6" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "has_tasks": true, "task_status": "10 of 15 tasks completed", "confidential": false, "discussion_locked": false, "_links":{ "self":"http://example.com/api/v4/projects/1/issues/76", "notes":"`http://example.com/`api/v4/projects/1/issues/76/notes", "award_emoji":"http://example.com/api/v4/projects/1/issues/76/award_emoji", "project":"http://example.com/api/v4/projects/1" }, "task_completion_status":{ "count":0, "completed_count":0 } } ] ``` 使用 GitLab [Starter,Bronze 或更高版本的用户](https://about.gitlab.com/pricing/)还将看到`weight`参数: ``` [ { "state" : "opened", "description" : "Ratione dolores corrupti mollitia soluta quia.", "weight": null, ... } ] ``` **注意** :不建议使用`assignee`列,现在我们将其显示为符合 GitLab EE API 的单一大小的数组`assignees` . **注意** : [GitLab 10.6](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042)中[引入了](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042) `closed_by`属性. 只有在 GitLab 10.6 之后关闭的问题以及关闭问题的用户帐户仍然存在时,才会显示此值. ## List group issues[](#list-group-issues "Permalink") 获取小组问题的列表. 如果该组是私有的,则需要提供凭据进行授权. 首选的方法是使用[个人访问令牌](../user/profile/personal_access_tokens.html) . ``` GET /groups/:id/issues GET /groups/:id/issues?state=opened GET /groups/:id/issues?state=closed GET /groups/:id/issues?labels=foo GET /groups/:id/issues?labels=foo,bar GET /groups/:id/issues?labels=foo,bar&state=opened GET /groups/:id/issues?milestone=1.0.0 GET /groups/:id/issues?milestone=1.0.0&state=opened GET /groups/:id/issues?iids[]=42&iids[]=43 GET /groups/:id/issues?search=issue+title+or+description GET /groups/:id/issues?author_id=5 GET /groups/:id/issues?assignee_id=5 GET /groups/:id/issues?my_reaction_emoji=star GET /groups/:id/issues?confidential=true ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 认证用户拥有[的组](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `state` | string | no | 返回所有问题,或者仅返回已`opened`或`closed` | | `labels` | string | no | 标签名称的逗号分隔列表,必须具有要返回的所有标签的问题. `None`列出所有没有标签的问题. `Any`列出至少带有一个标签的所有问题. `No+Label` (不推荐使用)列出所有问题且不带标签. 预定义名称不区分大小写. | | `with_labels_details` | boolean | no | 如果为`true` ,则响应将为标签字段中的每个标签返回更多详细信息`:name` , `:color` , `:description` , `:description_html` , `:text_color` . 默认值为`false` . [GitLab 12.7](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/21413)中引入了`description_html`属性 | | `iids[]` | 整数数组 | no | 仅返回具有给定`iid`的问题 | | `milestone` | string | no | 里程碑标题. `None`列出没有里程碑的所有问题. `Any`列出具有指定里程碑的所有问题. | | `scope` | string | no | 回到问题在给定范围: `created_by_me` , `assigned_to_me`或`all` . 对于 11.0 之前的版本,请改用现在不建议使用`created-by-me`范围或`created-by-me` `assigned-to-me`范围. *(在 GitLab 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13004) .在 GitLab 11.0 中[更改为 snake_case](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/18935) )* | | `author_id` | integer | no | 返回由给定用户`id`创建的问题. 与`author_username` . 与`scope=all`或`scope=assigned_to_me`结合使用. *(在 GitLab 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13004) )* | | `author_username` | string | no | 返回由给定`username`创建的问题. 类似于`author_id`并且与`author_id` . | | `assignee_id` | integer | no | 返回分配给给定用户`id` . 互斥与`assignee_username` . `None`返回未分配的问题. 受让人有`Any`退货问题. *(在 GitLab 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13004) )* | | `assignee_username` | 字符串数组 | no | 返回分配给给定`username` . 类似于`assignee_id`并且与`assignee_id`互斥. 在 GitLab CE 中, `assignee_username`数组应仅包含单个值,否则将返回无效的参数错误. | | `my_reaction_emoji` | string | no | 返回的问题由已验证的用户通过给定的`emoji`响应. `None`返回没有响应的问题. 至少有一个反应, `Any`回报问题. *(在 GitLab 10.0 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/14016) )* | | `weight` | integer | no | 以指定的`weight`返回问题. `None`返回没有分配权重的问题. 分配了权重的`Any`退货问题. | | `order_by` | string | no | 回到问题下令`created_at` , `updated_at` , `priority` , `due_date` , `relative_position` , `label_priority` , `milestone_due` , `popularity` , `weight`领域. 默认为`created_at` | | `sort` | string | no | 返回按`asc`或`desc`排列的问题. 默认为`desc` | | `search` | string | no | 搜索组问题的`title`和`description` | | `created_after` | datetime | no | 返回在给定时间或之后创建的问题 | | `created_before` | datetime | no | 返回在给定时间或之前创建的问题 | | `updated_after` | datetime | no | 返回在给定时间或之后更新的问题 | | `updated_before` | datetime | no | 返回在给定时间或之前更新的问题 | | `confidential` | boolean | no | 过滤机密或公共问题. | | `not` | Hash | no | 返回与提供的参数不匹配的问题. 接受: `labels` , `milestone` , `author_id` , `author_username` , `assignee_id` , `assignee_username` , `my_reaction_emoji` , `search` , `in` | | `non_archived` | boolean | no | 从未归档的项目返回问题. 默认为 true. *(在[GitLab 12.8 中](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/23785)引入)* | ``` curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/groups/4/issues" ``` 响应示例: ``` [ { "project_id" : 4, "milestone" : { "due_date" : null, "project_id" : 4, "state" : "closed", "description" : "Rerum est voluptatem provident consequuntur molestias similique ipsum dolor.", "iid" : 3, "id" : 11, "title" : "v3.0", "created_at" : "2016-01-04T15:31:39.788Z", "updated_at" : "2016-01-04T15:31:39.788Z" }, "author" : { "state" : "active", "web_url" : "https://gitlab.example.com/root", "avatar_url" : null, "username" : "root", "id" : 1, "name" : "Administrator" }, "description" : "Omnis vero earum sunt corporis dolor et placeat.", "state" : "closed", "iid" : 1, "assignees" : [{ "avatar_url" : null, "web_url" : "https://gitlab.example.com/lennie", "state" : "active", "username" : "lennie", "id" : 9, "name" : "Dr. Luella Kovacek" }], "assignee" : { "avatar_url" : null, "web_url" : "https://gitlab.example.com/lennie", "state" : "active", "username" : "lennie", "id" : 9, "name" : "Dr. Luella Kovacek" }, "labels" : ["foo", "bar"], "upvotes": 4, "downvotes": 0, "merge_requests_count": 0, "id" : 41, "title" : "Ut commodi ullam eos dolores perferendis nihil sunt.", "updated_at" : "2016-01-04T15:31:46.176Z", "created_at" : "2016-01-04T15:31:46.176Z", "closed_at" : null, "closed_by" : null, "user_notes_count": 1, "due_date": null, "web_url": "http://example.com/my-group/my-project/issues/1", "references": { "short": "#1", "relative": "my-project#1", "full": "my-group/my-project#1" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "has_tasks": true, "task_status": "10 of 15 tasks completed", "confidential": false, "discussion_locked": false, "_links":{ "self":"http://example.com/api/v4/projects/4/issues/41", "notes":"`http://example.com/`api/v4/projects/4/issues/41/notes", "award_emoji":"http://example.com/api/v4/projects/4/issues/41/award_emoji", "project":"http://example.com/api/v4/projects/4" }, "task_completion_status":{ "count":0, "completed_count":0 } } ] ``` Users on GitLab [Starter, Bronze, or higher](https://about.gitlab.com/pricing/) will also see the `weight` parameter: ``` [ { "project_id" : 4, "description" : "Omnis vero earum sunt corporis dolor et placeat.", "weight": null, ... } ] ``` **注意** :不建议使用`assignee`列,现在我们将其显示为符合 GitLab EE API 的单一大小的数组`assignees` . **注意** : [GitLab 10.6](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042)中[引入了](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042) `closed_by`属性. 只有在 GitLab 10.6 之后关闭的问题以及关闭问题的用户帐户仍然存在时,才会显示此值. ## List project issues[](#list-project-issues "Permalink") Get a list of a project’s issues. 如果项目为私人项目,则需要提供凭据进行授权. 首选的方法是使用[个人访问令牌](../user/profile/personal_access_tokens.html) . ``` GET /projects/:id/issues GET /projects/:id/issues?state=opened GET /projects/:id/issues?state=closed GET /projects/:id/issues?labels=foo GET /projects/:id/issues?labels=foo,bar GET /projects/:id/issues?labels=foo,bar&state=opened GET /projects/:id/issues?milestone=1.0.0 GET /projects/:id/issues?milestone=1.0.0&state=opened GET /projects/:id/issues?iids[]=42&iids[]=43 GET /projects/:id/issues?search=issue+title+or+description GET /projects/:id/issues?author_id=5 GET /projects/:id/issues?assignee_id=5 GET /projects/:id/issues?my_reaction_emoji=star GET /projects/:id/issues?confidential=true ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `iids[]` | 整数数组 | no | 仅返回具有给定`iid`的问题 | | `state` | string | no | 返回所有问题,或者仅返回已`opened`或`closed` | | `labels` | string | no | 标签名称的逗号分隔列表,必须具有要返回的所有标签的问题. `None`列出所有没有标签的问题. `Any`列出至少带有一个标签的所有问题. `No+Label` (不推荐使用)列出所有问题且不带标签. 预定义名称不区分大小写. | | `with_labels_details` | boolean | no | 如果为`true` ,则响应将为标签字段中的每个标签返回更多详细信息`:name` , `:color` , `:description` , `:description_html` , `:text_color` . 默认值为`false` . `description_html`在[GitLab 12.7 中](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/21413)引入 | | `milestone` | string | no | 里程碑标题. `None`列出没有里程碑的所有问题. `Any`列出具有指定里程碑的所有问题. | | `scope` | string | no | 回到问题在给定范围: `created_by_me` , `assigned_to_me`或`all` . 对于 11.0 之前的版本,请改用现在不建议使用`created-by-me`范围或`created-by-me` `assigned-to-me`范围. *(在 GitLab 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13004) .在 GitLab 11.0 中[更改为 snake_case](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/18935) )* | | `author_id` | integer | no | 返回由给定用户`id`创建的问题. 与`author_username` . 与`scope=all`或`scope=assigned_to_me`结合使用. *(在 GitLab 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13004) )* | | `author_username` | string | no | 返回由给定`username`创建的问题. 类似于`author_id`并且与`author_id` . | | `assignee_id` | integer | no | 返回分配给给定用户`id` . 互斥与`assignee_username` . `None`返回未分配的问题. 受让人有`Any`退货问题. *(在 GitLab 9.5 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/13004) )* | | `assignee_username` | 字符串数组 | no | 返回分配给给定`username` . 类似于`assignee_id`并且与`assignee_id`互斥. 在 GitLab CE 中, `assignee_username`数组应仅包含单个值,否则将返回无效的参数错误. | | `my_reaction_emoji` | string | no | 返回的问题由已验证的用户通过给定的`emoji`响应. `None`返回没有响应的问题. 至少有一个反应, `Any`回报问题. *(在 GitLab 10.0 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/14016) )* | | `weight` | integer | no | 以指定的`weight`返回问题. `None`返回没有分配权重的问题. 分配了权重的`Any`退货问题. | | `order_by` | string | no | 回到问题下令`created_at` , `updated_at` , `priority` , `due_date` , `relative_position` , `label_priority` , `milestone_due` , `popularity` , `weight`领域. 默认为`created_at` | | `sort` | string | no | 返回按`asc`或`desc`排列的问题. 默认为`desc` | | `search` | string | no | 根据`title`和`description`搜索项目问题 | | `created_after` | datetime | no | 返回在给定时间或之后创建的问题 | | `created_before` | datetime | no | 返回在给定时间或之前创建的问题 | | `updated_after` | datetime | no | 返回在给定时间或之后更新的问题 | | `updated_before` | datetime | no | 返回在给定时间或之前更新的问题 | | `confidential` | boolean | no | 过滤机密或公共问题. | | `not` | Hash | no | 返回与提供的参数不匹配的问题. 接受: `labels` , `milestone` , `author_id` , `author_username` , `assignee_id` , `assignee_username` , `my_reaction_emoji` , `search` , `in` | ``` curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/4/issues" ``` 响应示例: ``` [ { "project_id" : 4, "milestone" : { "due_date" : null, "project_id" : 4, "state" : "closed", "description" : "Rerum est voluptatem provident consequuntur molestias similique ipsum dolor.", "iid" : 3, "id" : 11, "title" : "v3.0", "created_at" : "2016-01-04T15:31:39.788Z", "updated_at" : "2016-01-04T15:31:39.788Z" }, "author" : { "state" : "active", "web_url" : "https://gitlab.example.com/root", "avatar_url" : null, "username" : "root", "id" : 1, "name" : "Administrator" }, "description" : "Omnis vero earum sunt corporis dolor et placeat.", "state" : "closed", "iid" : 1, "assignees" : [{ "avatar_url" : null, "web_url" : "https://gitlab.example.com/lennie", "state" : "active", "username" : "lennie", "id" : 9, "name" : "Dr. Luella Kovacek" }], "assignee" : { "avatar_url" : null, "web_url" : "https://gitlab.example.com/lennie", "state" : "active", "username" : "lennie", "id" : 9, "name" : "Dr. Luella Kovacek" }, "labels" : ["foo", "bar"], "upvotes": 4, "downvotes": 0, "merge_requests_count": 0, "id" : 41, "title" : "Ut commodi ullam eos dolores perferendis nihil sunt.", "updated_at" : "2016-01-04T15:31:46.176Z", "created_at" : "2016-01-04T15:31:46.176Z", "closed_at" : "2016-01-05T15:31:46.176Z", "closed_by" : { "state" : "active", "web_url" : "https://gitlab.example.com/root", "avatar_url" : null, "username" : "root", "id" : 1, "name" : "Administrator" }, "user_notes_count": 1, "due_date": "2016-07-22", "web_url": "http://example.com/my-group/my-project/issues/1", "references": { "short": "#1", "relative": "#1", "full": "my-group/my-project#1" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "has_tasks": true, "task_status": "10 of 15 tasks completed", "confidential": false, "discussion_locked": false, "_links":{ "self":"http://example.com/api/v4/projects/4/issues/41", "notes":"`http://example.com/`api/v4/projects/4/issues/41/notes", "award_emoji":"http://example.com/api/v4/projects/4/issues/41/award_emoji", "project":"http://example.com/api/v4/projects/4" }, "task_completion_status":{ "count":0, "completed_count":0 } } ] ``` 使用 GitLab [Starter,Bronze 或更高版本的用户](https://about.gitlab.com/pricing/)还将看到`weight`参数: ``` [ { "project_id" : 4, "description" : "Omnis vero earum sunt corporis dolor et placeat.", "weight": null, ... } ] ``` **注意** :不建议使用`assignee`列,现在我们将其显示为符合 GitLab EE API 的单一大小的数组`assignees` . **注意** : [GitLab 10.6](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042)中[引入了](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042) `closed_by`属性. 只有在 GitLab 10.6 之后关闭的问题以及关闭问题的用户帐户仍然存在时,才会显示此值. ## Single issue[](#single-issue "Permalink") 获得单个项目问题. 如果项目为私人项目或问题为机密,则需要提供凭据进行授权. 首选的方法是使用[个人访问令牌](../user/profile/personal_access_tokens.html) . ``` GET /projects/:id/issues/:issue_iid ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `issue_iid` | integer | yes | The internal ID of a project’s issue | ``` curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/4/issues/41" ``` 响应示例: ``` { "project_id" : 4, "milestone" : { "due_date" : null, "project_id" : 4, "state" : "closed", "description" : "Rerum est voluptatem provident consequuntur molestias similique ipsum dolor.", "iid" : 3, "id" : 11, "title" : "v3.0", "created_at" : "2016-01-04T15:31:39.788Z", "updated_at" : "2016-01-04T15:31:39.788Z", "closed_at" : "2016-01-05T15:31:46.176Z" }, "author" : { "state" : "active", "web_url" : "https://gitlab.example.com/root", "avatar_url" : null, "username" : "root", "id" : 1, "name" : "Administrator" }, "description" : "Omnis vero earum sunt corporis dolor et placeat.", "state" : "closed", "iid" : 1, "assignees" : [{ "avatar_url" : null, "web_url" : "https://gitlab.example.com/lennie", "state" : "active", "username" : "lennie", "id" : 9, "name" : "Dr. Luella Kovacek" }], "assignee" : { "avatar_url" : null, "web_url" : "https://gitlab.example.com/lennie", "state" : "active", "username" : "lennie", "id" : 9, "name" : "Dr. Luella Kovacek" }, "labels" : [], "upvotes": 4, "downvotes": 0, "merge_requests_count": 0, "id" : 41, "title" : "Ut commodi ullam eos dolores perferendis nihil sunt.", "updated_at" : "2016-01-04T15:31:46.176Z", "created_at" : "2016-01-04T15:31:46.176Z", "closed_at" : null, "closed_by" : null, "subscribed": false, "user_notes_count": 1, "due_date": null, "web_url": "http://example.com/my-group/my-project/issues/1", "references": { "short": "#1", "relative": "#1", "full": "my-group/my-project#1" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "confidential": false, "discussion_locked": false, "_links": { "self": "http://example.com/api/v4/projects/1/issues/2", "notes": "http://example.com/api/v4/projects/1/issues/2/notes", "award_emoji": "http://example.com/api/v4/projects/1/issues/2/award_emoji", "project": "http://example.com/api/v4/projects/1" }, "task_completion_status":{ "count":0, "completed_count":0 } } ``` 使用 GitLab [Starter,Bronze 或更高版本的用户](https://about.gitlab.com/pricing/)还将看到`weight`参数: ``` { "project_id" : 4, "description" : "Omnis vero earum sunt corporis dolor et placeat.", "weight": null, ... } ``` 使用 GitLab [Premium 的](https://about.gitlab.com/pricing/)用户还将看到`epic`属性: ``` { "project_id" : 4, "description" : "Omnis vero earum sunt corporis dolor et placeat.", "epic_iid" : 5, //deprecated, use `iid` of the `epic` attribute "epic": { "id" : 42, "iid" : 5, "title": "My epic epic", "url" : "/groups/h5bp/-/epics/5", "group_id": 8 }, // ... } ``` **注意** :不建议使用`assignee`列,现在我们将其显示为符合 GitLab EE API 的单一大小的数组`assignees` . **注意** : [GitLab 10.6](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042)中[引入了](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042) `closed_by`属性. 只有在 GitLab 10.6 之后关闭的问题以及关闭问题的用户帐户仍然存在时,才会显示此值. **注意** : `epic_iid`属性已过时, [将在版本 5 中删除](https://gitlab.com/gitlab-org/gitlab/-/issues/35157) . 请改用`epic`属性的`iid` . ## New issue[](#new-issue "Permalink") 创建一个新的项目问题. ``` POST /projects/:id/issues ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `iid` | integer/string | no | 项目问题的内部 ID(需要管理员或项目所有者权限) | | `title` | string | yes | 问题标题 | | `description` | string | no | 问题的描述. 限制为 1,048,576 个字符. | | `confidential` | boolean | no | 将问题设置为机密. 默认值为`false` . | | `assignee_ids` | 整数数组 | no | 要分配问题的用户的 ID | | `milestone_id` | integer | no | 分配问题的里程碑的全局 ID | | `labels` | string | no | 问题的逗号分隔标签名称 | | `created_at` | string | no | 日期时间字符串,ISO 8601 格式,例如`2016-03-11T03:45:40Z` (需要管理员或项目/组所有者权限) | | `due_date` | string | no | 日期时间字符串,格式为 YEAR-MONTH-DAY,例如`2016-03-11` | | `merge_request_to_resolve_discussions_of` | integer | no | 解决所有问题的合并请求的 IID. 这将使用默认描述填充问题,并将所有讨论标记为已解决. 传递描述或标题时,这些值将优先于默认值. | | `discussion_to_resolve` | string | no | 要解决的讨论的​​ID. 这将使用默认描述填充问题,并将讨论标记为已解决. 与`merge_request_to_resolve_discussions_of`结合使用. | | `weight` | integer | no | 问题的分量. 有效值大于或等于 0. | | `epic_id` | integer | no | 要添加问题的史诗的 ID. 有效值大于或等于 0. | | `epic_iid` | integer | no | 要添加问题的史诗的 IID. 有效值大于或等于 0.(不建议使用, [将在版本 5 中将其删除](https://gitlab.com/gitlab-org/gitlab/-/issues/35157) ) | ``` curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/4/issues?title=Issues%20with%20auth&labels=bug" ``` 响应示例: ``` { "project_id" : 4, "id" : 84, "created_at" : "2016-01-07T12:44:33.959Z", "iid" : 14, "title" : "Issues with auth", "state" : "opened", "assignees" : [], "assignee" : null, "labels" : [ "bug" ], "upvotes": 4, "downvotes": 0, "merge_requests_count": 0, "author" : { "name" : "Alexandra Bashirian", "avatar_url" : null, "state" : "active", "web_url" : "https://gitlab.example.com/eileen.lowe", "id" : 18, "username" : "eileen.lowe" }, "description" : null, "updated_at" : "2016-01-07T12:44:33.959Z", "closed_at" : null, "closed_by" : null, "milestone" : null, "subscribed" : true, "user_notes_count": 0, "due_date": null, "web_url": "http://example.com/my-group/my-project/issues/14", "references": { "short": "#14", "relative": "#14", "full": "my-group/my-project#14" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "confidential": false, "discussion_locked": false, "_links": { "self": "http://example.com/api/v4/projects/1/issues/2", "notes": "http://example.com/api/v4/projects/1/issues/2/notes", "award_emoji": "http://example.com/api/v4/projects/1/issues/2/award_emoji", "project": "http://example.com/api/v4/projects/1" }, "task_completion_status":{ "count":0, "completed_count":0 } } ``` 使用 GitLab [Starter,Bronze 或更高版本的用户](https://about.gitlab.com/pricing/)还将看到`weight`参数: ``` { "project_id" : 4, "description" : null, "weight": null, ... } ``` **注意** :不建议使用`assignee`列,现在我们将其显示为符合 GitLab EE API 的单一大小的数组`assignees` . **注意** : [GitLab 10.6](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042)中[引入了](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042) `closed_by`属性. 只有在 GitLab 10.6 之后关闭的问题以及关闭问题的用户帐户仍然存在时,才会显示此值. ## Rate limits[](#rate-limits "Permalink") 为了避免滥用,用户仅限于: | 请求类型 | Limit | | --- | --- | | Create | 每分钟 300 期 | ## Edit issue[](#edit-issue "Permalink") 更新现有项目问题. 此调用还用于将问题标记为已结束. ``` PUT /projects/:id/issues/:issue_iid ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `issue_iid` | integer | yes | 项目问题的内部 ID | | `title` | string | no | 问题标题 | | `description` | string | no | 问题的描述. 限制为 1,048,576 个字符. | | `confidential` | boolean | no | 将问题更新为机密 | | `assignee_ids` | 整数数组 | no | 要分配问题的用户的 ID. 设置为`0`或提供一个空值以取消分配所有受让人. | | `milestone_id` | integer | no | 要分配问题的里程碑的全局 ID. 设置为`0`或提供一个空值以取消分配里程碑. | | `labels` | string | no | 问题的标签名称,以逗号分隔. 设置为空字符串以取消分配所有标签. | | `add_labels` | string | no | 以逗号分隔的标签名称添加到问题中. | | `remove_labels` | string | no | 逗号分隔的标签名称可从问题中删除. | | `state_event` | string | no | 问题的状态事件. 设为`close`以关闭问题,然后`reopen`以重新打开它 | | `updated_at` | string | no | 日期时间字符串,ISO 8601 格式,例如`2016-03-11T03:45:40Z` (需要管理员或项目所有者权限). 不接受空字符串或空值. | | `due_date` | string | no | 日期时间字符串,格式为 YEAR-MONTH-DAY,例如`2016-03-11` | | `weight` | integer | no | 问题的分量. 有效值大于或等于 0.0 | | `discussion_locked` | boolean | no | 指示问题的讨论是否被锁定的标志. 如果讨论被锁定,则只有项目成员可以添加或编辑评论. | | `epic_id` | integer | no | 要添加问题的史诗的 ID. 有效值大于或等于 0. | | `epic_iid` | integer | no | 要添加问题的史诗的 IID. 有效值大于或等于 0.(不建议使用, [将在版本 5 中将其删除](https://gitlab.com/gitlab-org/gitlab/-/issues/35157) ) | ``` curl --request PUT --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/4/issues/85?state_event=close" ``` 响应示例: ``` { "created_at" : "2016-01-07T12:46:01.410Z", "author" : { "name" : "Alexandra Bashirian", "avatar_url" : null, "username" : "eileen.lowe", "id" : 18, "state" : "active", "web_url" : "https://gitlab.example.com/eileen.lowe" }, "state" : "closed", "title" : "Issues with auth", "project_id" : 4, "description" : null, "updated_at" : "2016-01-07T12:55:16.213Z", "closed_at" : "2016-01-08T12:55:16.213Z", "closed_by" : { "state" : "active", "web_url" : "https://gitlab.example.com/root", "avatar_url" : null, "username" : "root", "id" : 1, "name" : "Administrator" }, "iid" : 15, "labels" : [ "bug" ], "upvotes": 4, "downvotes": 0, "merge_requests_count": 0, "id" : 85, "assignees" : [], "assignee" : null, "milestone" : null, "subscribed" : true, "user_notes_count": 0, "due_date": "2016-07-22", "web_url": "http://example.com/my-group/my-project/issues/15", "references": { "short": "#15", "relative": "#15", "full": "my-group/my-project#15" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "confidential": false, "discussion_locked": false, "_links": { "self": "http://example.com/api/v4/projects/1/issues/2", "notes": "http://example.com/api/v4/projects/1/issues/2/notes", "award_emoji": "http://example.com/api/v4/projects/1/issues/2/award_emoji", "project": "http://example.com/api/v4/projects/1" }, "task_completion_status":{ "count":0, "completed_count":0 } } ``` 使用 GitLab [Starter,Bronze 或更高版本的用户](https://about.gitlab.com/pricing/)还将看到`weight`参数: ``` { "project_id" : 4, "description" : null, "weight": null, ... } ``` **注:**至少以下参数之一是需要传递的请求是成功的: `:assignee_id` , `:assignee_ids` , `:confidential` , `:created_at` , `:description` , `:discussion_locked` , `:due_date` , `:labels` , `:milestone_id` , `:state_event` ,或`:title` .**注意:**不建议使用`assignee`列. 现在,我们将其显示为符合 GitLab EE API 的单个大小的数组`assignees` .**注意:** `closed_by`属性是[在 GitLab 10.6](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042)中[引入的](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042) . 只有在 GitLab 10.6 之后关闭的问题以及关闭问题的用户帐户仍然存在时,才会显示此值. ## Delete an issue[](#delete-an-issue "Permalink") 仅适用于管理员和项目所有者. 删除相关问题. ``` DELETE /projects/:id/issues/:issue_iid ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `issue_iid` | integer | yes | 项目问题的内部 ID | ``` curl --request DELETE --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/4/issues/85" ``` ## Reorder an issue[](#reorder-an-issue "Permalink") > 作为[社区贡献](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/35349) [引入](https://gitlab.com/gitlab-org/gitlab/-/issues/211864)到 GitLab 13.2 中. 重新排序问题,手动排序问题时可以看到结果 ``` PUT /projects/:id/issues/:issue_iid/reorder ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `issue_iid` | integer | yes | 项目问题的内部 ID | | `move_after_id` | integer | no | 一个项目的 ID,以便在以后移动此问题 | | `move_before_id` | integer | no | 一个项目的 ID,以便在此之前移此问题 | ``` curl --request PUT --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/4/issues/85/reorder?move_after_id=51&move_before_id=92" ``` ## Move an issue[](#move-an-issue "Permalink") 将问题移到其他项目. 如果目标项目等于源项目,或者用户没有足够的权限来移动问题,则返回错误`400`和解释性错误消息. If a given label and/or milestone with the same name also exists in the target project, it will then be assigned to the issue that is being moved. ``` POST /projects/:id/issues/:issue_iid/move ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `issue_iid` | integer | yes | 项目问题的内部 ID | | `to_project_id` | integer | yes | 新项目的 ID | ``` curl --header "PRIVATE-TOKEN: " --form to_project_id=5 "https://gitlab.example.com/api/v4/projects/4/issues/85/move" ``` Example response: ``` { "id": 92, "iid": 11, "project_id": 5, "title": "Sit voluptas tempora quisquam aut doloribus et.", "description": "Repellat voluptas quibusdam voluptatem exercitationem.", "state": "opened", "created_at": "2016-04-05T21:41:45.652Z", "updated_at": "2016-04-07T12:20:17.596Z", "closed_at": null, "closed_by": null, "labels": [], "upvotes": 4, "downvotes": 0, "merge_requests_count": 0, "milestone": null, "assignees": [{ "name": "Miss Monserrate Beier", "username": "axel.block", "id": 12, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon", "web_url": "https://gitlab.example.com/axel.block" }], "assignee": { "name": "Miss Monserrate Beier", "username": "axel.block", "id": 12, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon", "web_url": "https://gitlab.example.com/axel.block" }, "author": { "name": "Kris Steuber", "username": "solon.cremin", "id": 10, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/7a190fecbaa68212a4b68aeb6e3acd10?s=80&d=identicon", "web_url": "https://gitlab.example.com/solon.cremin" }, "due_date": null, "web_url": "http://example.com/my-group/my-project/issues/11", "references": { "short": "#11", "relative": "#11", "full": "my-group/my-project#11" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "confidential": false, "discussion_locked": false, "_links": { "self": "http://example.com/api/v4/projects/1/issues/2", "notes": "http://example.com/api/v4/projects/1/issues/2/notes", "award_emoji": "http://example.com/api/v4/projects/1/issues/2/award_emoji", "project": "http://example.com/api/v4/projects/1" }, "task_completion_status":{ "count":0, "completed_count":0 } } ``` 使用 GitLab [Starter,Bronze 或更高版本的用户](https://about.gitlab.com/pricing/)还将看到`weight`参数: ``` { "project_id": 5, "description": "Repellat voluptas quibusdam voluptatem exercitationem.", "weight": null, ... } ``` **注意** :不建议使用`assignee`列,现在我们将其显示为符合 GitLab EE API 的单一大小的数组`assignees` . **注意** : [GitLab 10.6](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042)中[引入了](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042) `closed_by`属性. 只有在 GitLab 10.6 之后关闭的问题以及关闭问题的用户帐户仍然存在时,才会显示此值. ## Subscribe to an issue[](#subscribe-to-an-issue "Permalink") 为经过身份验证的用户订阅问题以接收通知. 如果用户已经订阅了该问题,则返回状态码`304` . ``` POST /projects/:id/issues/:issue_iid/subscribe ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `issue_iid` | integer | yes | 项目问题的内部 ID | ``` curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/5/issues/93/subscribe" ``` 响应示例: ``` { "id": 92, "iid": 11, "project_id": 5, "title": "Sit voluptas tempora quisquam aut doloribus et.", "description": "Repellat voluptas quibusdam voluptatem exercitationem.", "state": "opened", "created_at": "2016-04-05T21:41:45.652Z", "updated_at": "2016-04-07T12:20:17.596Z", "closed_at": null, "closed_by": null, "labels": [], "upvotes": 4, "downvotes": 0, "merge_requests_count": 0, "milestone": null, "assignees": [{ "name": "Miss Monserrate Beier", "username": "axel.block", "id": 12, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon", "web_url": "https://gitlab.example.com/axel.block" }], "assignee": { "name": "Miss Monserrate Beier", "username": "axel.block", "id": 12, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon", "web_url": "https://gitlab.example.com/axel.block" }, "author": { "name": "Kris Steuber", "username": "solon.cremin", "id": 10, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/7a190fecbaa68212a4b68aeb6e3acd10?s=80&d=identicon", "web_url": "https://gitlab.example.com/solon.cremin" }, "due_date": null, "web_url": "http://example.com/my-group/my-project/issues/11", "references": { "short": "#11", "relative": "#11", "full": "my-group/my-project#11" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "confidential": false, "discussion_locked": false, "_links": { "self": "http://example.com/api/v4/projects/1/issues/2", "notes": "http://example.com/api/v4/projects/1/issues/2/notes", "award_emoji": "http://example.com/api/v4/projects/1/issues/2/award_emoji", "project": "http://example.com/api/v4/projects/1" }, "task_completion_status":{ "count":0, "completed_count":0 } } ``` 使用 GitLab [Starter,Bronze 或更高版本的用户](https://about.gitlab.com/pricing/)还将看到`weight`参数: ``` { "project_id": 5, "description": "Repellat voluptas quibusdam voluptatem exercitationem.", "weight": null, ... } ``` **注意** :不建议使用`assignee`列,现在我们将其显示为符合 GitLab EE API 的单一大小的数组`assignees` . **注意** : [GitLab 10.6](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042)中[引入了](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042) `closed_by`属性. 只有在 GitLab 10.6 之后关闭的问题以及关闭问题的用户帐户仍然存在时,才会显示此值. ## Unsubscribe from an issue[](#unsubscribe-from-an-issue "Permalink") 从问题中退订已认证的用户,以不接收来自该问题的通知. 如果用户未订阅该问题,则返回状态码`304` . ``` POST /projects/:id/issues/:issue_iid/unsubscribe ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `issue_iid` | integer | yes | 项目问题的内部 ID | ``` curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/5/issues/93/unsubscribe" ``` 响应示例: ``` { "id": 93, "iid": 12, "project_id": 5, "title": "Incidunt et rerum ea expedita iure quibusdam.", "description": "Et cumque architecto sed aut ipsam.", "state": "opened", "created_at": "2016-04-05T21:41:45.217Z", "updated_at": "2016-04-07T13:02:37.905Z", "labels": [], "upvotes": 4, "downvotes": 0, "merge_requests_count": 0, "milestone": null, "assignee": { "name": "Edwardo Grady", "username": "keyon", "id": 21, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/3e6f06a86cf27fa8b56f3f74f7615987?s=80&d=identicon", "web_url": "https://gitlab.example.com/keyon" }, "closed_at": null, "closed_by": null, "author": { "name": "Vivian Hermann", "username": "orville", "id": 11, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/5224fd70153710e92fb8bcf79ac29d67?s=80&d=identicon", "web_url": "https://gitlab.example.com/orville" }, "subscribed": false, "due_date": null, "web_url": "http://example.com/my-group/my-project/issues/12", "references": { "short": "#12", "relative": "#12", "full": "my-group/my-project#12" }, "confidential": false, "discussion_locked": false, "task_completion_status":{ "count":0, "completed_count":0 } } ``` ## Create a todo[](#create-a-todo "Permalink") 在问题上为当前用户手动创建待办事项. 如果在该问题上已经存在用户的待办事项,则返回状态码`304` . ``` POST /projects/:id/issues/:issue_iid/todo ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `issue_iid` | integer | yes | 项目问题的内部 ID | ``` curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/5/issues/93/todo" ``` 响应示例: ``` { "id": 112, "project": { "id": 5, "name": "GitLab CI/CD", "name_with_namespace": "GitLab Org / GitLab CI/CD", "path": "gitlab-ci", "path_with_namespace": "gitlab-org/gitlab-ci" }, "author": { "name": "Administrator", "username": "root", "id": 1, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", "web_url": "https://gitlab.example.com/root" }, "action_name": "marked", "target_type": "Issue", "target": { "id": 93, "iid": 10, "project_id": 5, "title": "Vel voluptas atque dicta mollitia adipisci qui at.", "description": "Tempora laboriosam sint magni sed voluptas similique.", "state": "closed", "created_at": "2016-06-17T07:47:39.486Z", "updated_at": "2016-07-01T11:09:13.998Z", "labels": [], "milestone": { "id": 26, "iid": 1, "project_id": 5, "title": "v0.0", "description": "Accusantium nostrum rerum quae quia quis nesciunt suscipit id.", "state": "closed", "created_at": "2016-06-17T07:47:33.832Z", "updated_at": "2016-06-17T07:47:33.832Z", "due_date": null }, "assignees": [{ "name": "Jarret O'Keefe", "username": "francisca", "id": 14, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/a7fa515d53450023c83d62986d0658a8?s=80&d=identicon", "web_url": "https://gitlab.example.com/francisca" }], "assignee": { "name": "Jarret O'Keefe", "username": "francisca", "id": 14, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/a7fa515d53450023c83d62986d0658a8?s=80&d=identicon", "web_url": "https://gitlab.example.com/francisca" }, "author": { "name": "Maxie Medhurst", "username": "craig_rutherford", "id": 12, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/a0d477b3ea21970ce6ffcbb817b0b435?s=80&d=identicon", "web_url": "https://gitlab.example.com/craig_rutherford" }, "subscribed": true, "user_notes_count": 7, "upvotes": 0, "downvotes": 0, "merge_requests_count": 0, "due_date": null, "web_url": "http://example.com/my-group/my-project/issues/10", "references": { "short": "#10", "relative": "#10", "full": "my-group/my-project#10" }, "confidential": false, "discussion_locked": false, "task_completion_status":{ "count":0, "completed_count":0 } }, "target_url": "https://gitlab.example.com/gitlab-org/gitlab-ci/issues/10", "body": "Vel voluptas atque dicta mollitia adipisci qui at.", "state": "pending", "created_at": "2016-07-01T11:09:13.992Z" } ``` **注意** :不建议使用`assignee`列,现在我们将其显示为符合 GitLab EE API 的单一大小的数组`assignees` . **注意** : [GitLab 10.6](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042)中[引入了](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/17042) `closed_by`属性. 只有在 GitLab 10.6 之后关闭的问题以及关闭问题的用户帐户仍然存在时,才会显示此值. ## Set a time estimate for an issue[](#set-a-time-estimate-for-an-issue "Permalink") 设置此问题的估计工作时间. ``` POST /projects/:id/issues/:issue_iid/time_estimate ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `issue_iid` | integer | yes | 项目问题的内部 ID | | `duration` | string | yes | 以人类格式表示的持续时间. 例如:3h30m | ``` curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/5/issues/93/time_estimate?duration=3h30m" ``` 响应示例: ``` { "human_time_estimate": "3h 30m", "human_total_time_spent": null, "time_estimate": 12600, "total_time_spent": 0 } ``` ## Reset the time estimate for an issue[](#reset-the-time-estimate-for-an-issue "Permalink") 将此问题的估计时间重置为 0 秒. ``` POST /projects/:id/issues/:issue_iid/reset_time_estimate ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `issue_iid` | integer | yes | 项目问题的内部 ID | ``` curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/5/issues/93/reset_time_estimate" ``` 响应示例: ``` { "human_time_estimate": null, "human_total_time_spent": null, "time_estimate": 0, "total_time_spent": 0 } ``` ## Add spent time for an issue[](#add-spent-time-for-an-issue "Permalink") 增加了解决此问题的时间 ``` POST /projects/:id/issues/:issue_iid/add_spent_time ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `issue_iid` | integer | yes | 项目问题的内部 ID | | `duration` | string | yes | 以人类格式表示的持续时间. 例如:3h30m | ``` curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/5/issues/93/add_spent_time?duration=1h" ``` Example response: ``` { "human_time_estimate": null, "human_total_time_spent": "1h", "time_estimate": 0, "total_time_spent": 3600 } ``` ## Reset spent time for an issue[](#reset-spent-time-for-an-issue "Permalink") 将此问题的总花费时间重置为 0 秒. ``` POST /projects/:id/issues/:issue_iid/reset_spent_time ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `issue_iid` | integer | yes | 项目问题的内部 ID | ``` curl --request POST --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/5/issues/93/reset_spent_time" ``` 响应示例: ``` { "human_time_estimate": null, "human_total_time_spent": null, "time_estimate": 0, "total_time_spent": 0 } ``` ## Get time tracking stats[](#get-time-tracking-stats "Permalink") 如果项目为私人项目或问题为机密,则需要提供凭据进行授权. 首选的方法是使用[个人访问令牌](../user/profile/personal_access_tokens.html) . ``` GET /projects/:id/issues/:issue_iid/time_stats ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `issue_iid` | integer | yes | 项目问题的内部 ID | ``` curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/5/issues/93/time_stats" ``` 响应示例: ``` { "human_time_estimate": "2h", "human_total_time_spent": "1h", "time_estimate": 7200, "total_time_spent": 3600 } ``` ## List merge requests related to issue[](#list-merge-requests-related-to-issue "Permalink") 获取与该问题相关的所有合并请求. 如果项目为私人项目或问题为机密,则需要提供凭据进行授权. 首选的方法是使用[个人访问令牌](../user/profile/personal_access_tokens.html) . ``` GET /projects/:id/issues/:issue_id/related_merge_requests ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `issue_iid` | integer | yes | 项目问题的内部 ID | ``` curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/1/issues/11/related_merge_requests" ``` 响应示例: ``` [ { "id": 29, "iid": 11, "project_id": 1, "title": "Provident eius eos blanditiis consequatur neque odit.", "description": "Ut consequatur ipsa aspernatur quisquam voluptatum fugit. Qui harum corporis quo fuga ut incidunt veritatis. Autem necessitatibus et harum occaecati nihil ea.\r\n\r\ntwitter/flight#8", "state": "opened", "created_at": "2018-09-18T14:36:15.510Z", "updated_at": "2018-09-19T07:45:13.089Z", "closed_by": null, "closed_at": null, "target_branch": "v2.x", "source_branch": "so_long_jquery", "user_notes_count": 9, "upvotes": 0, "downvotes": 0, "author": { "id": 14, "name": "Verna Hills", "username": "lawanda_reinger", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/de68a91aeab1cff563795fb98a0c2cc0?s=80&d=identicon", "web_url": "https://gitlab.example.com/lawanda_reinger" }, "assignee": { "id": 19, "name": "Jody Baumbach", "username": "felipa.kuvalis", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/6541fc75fc4e87e203529bd275fafd07?s=80&d=identicon", "web_url": "https://gitlab.example.com/felipa.kuvalis" }, "source_project_id": 1, "target_project_id": 1, "labels": [], "work_in_progress": false, "milestone": { "id": 27, "iid": 2, "project_id": 1, "title": "v1.0", "description": "Et tenetur voluptatem minima doloribus vero dignissimos vitae.", "state": "active", "created_at": "2018-09-18T14:35:44.353Z", "updated_at": "2018-09-18T14:35:44.353Z", "due_date": null, "start_date": null, "web_url": "https://gitlab.example.com/twitter/flight/milestones/2" }, "merge_when_pipeline_succeeds": false, "merge_status": "cannot_be_merged", "sha": "3b7b528e9353295c1c125dad281ac5b5deae5f12", "merge_commit_sha": null, "squash_commit_sha": null, "discussion_locked": null, "should_remove_source_branch": null, "force_remove_source_branch": false, "reference": "!11", "web_url": "https://gitlab.example.com/twitter/flight/merge_requests/4", "references": { "short": "!4", "relative": "!4", "full": "twitter/flight!4" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null }, "squash": false, "task_completion_status": { "count": 0, "completed_count": 0 }, "changes_count": "10", "latest_build_started_at": "2018-12-05T01:16:41.723Z", "latest_build_finished_at": "2018-12-05T02:35:54.046Z", "first_deployed_to_production_at": null, "pipeline": { "id": 38980952, "sha": "81c6a84c7aebd45a1ac2c654aa87f11e32338e0a", "ref": "test-branch", "status": "success", "web_url": "https://gitlab.com/gitlab-org/gitlab/pipelines/38980952" }, "head_pipeline": { "id": 38980952, "sha": "81c6a84c7aebd45a1ac2c654aa87f11e32338e0a", "ref": "test-branch", "status": "success", "web_url": "https://gitlab.example.com/twitter/flight/pipelines/38980952", "before_sha": "3c738a37eb23cf4c0ed0d45d6ddde8aad4a8da51", "tag": false, "yaml_errors": null, "user": { "id": 19, "name": "Jody Baumbach", "username": "felipa.kuvalis", "state": "active", "avatar_url": "https://www.gravatar.com/avatar/6541fc75fc4e87e203529bd275fafd07?s=80&d=identicon", "web_url": "https://gitlab.example.com/felipa.kuvalis" }, "created_at": "2018-12-05T01:16:13.342Z", "updated_at": "2018-12-05T02:35:54.086Z", "started_at": "2018-12-05T01:16:41.723Z", "finished_at": "2018-12-05T02:35:54.046Z", "committed_at": null, "duration": 4436, "coverage": "46.68", "detailed_status": { "icon": "status_warning", "text": "passed", "label": "passed with warnings", "group": "success-with-warnings", "tooltip": "passed", "has_details": true, "details_path": "/twitter/flight/pipelines/38", "illustration": null, "favicon": "https://gitlab.example.com/assets/ci_favicons/favicon_status_success-8451333011eee8ce9f2ab25dc487fe24a8758c694827a582f17f42b0a90446a2.png" } }, "diff_refs": { "base_sha": "d052d768f0126e8cddf80afd8b1eb07f406a3fcb", "head_sha": "81c6a84c7aebd45a1ac2c654aa87f11e32338e0a", "start_sha": "d052d768f0126e8cddf80afd8b1eb07f406a3fcb" }, "merge_error": null, "user": { "can_merge": true } } ] ``` ## List merge requests that will close issue on merge[](#list-merge-requests-that-will-close-issue-on-merge "Permalink") 获取所有合并请求,这些合并请求将在合并时关闭问题. 如果项目为私人项目或问题为机密,则需要提供凭据进行授权. 首选的方法是使用[个人访问令牌](../user/profile/personal_access_tokens.html) . ``` GET /projects/:id/issues/:issue_iid/closed_by ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer | yes | 项目 ID | | `issue_iid` | integer | yes | 项目问题的内部 ID | ``` curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/1/issues/11/closed_by" ``` 响应示例: ``` [ { "id": 6471, "iid": 6432, "project_id": 1, "title": "add a test for cgi lexer options", "description": "closes #11", "state": "opened", "created_at": "2017-04-06T18:33:34.168Z", "updated_at": "2017-04-09T20:10:24.983Z", "target_branch": "master", "source_branch": "feature.custom-highlighting", "upvotes": 0, "downvotes": 0, "author": { "name": "Administrator", "username": "root", "id": 1, "state": "active", "avatar_url": "http://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", "web_url": "https://gitlab.example.com/root" }, "assignee": null, "source_project_id": 1, "target_project_id": 1, "closed_at": null, "closed_by": null, "labels": [], "work_in_progress": false, "milestone": null, "merge_when_pipeline_succeeds": false, "merge_status": "unchecked", "sha": "5a62481d563af92b8e32d735f2fa63b94e806835", "merge_commit_sha": null, "squash_commit_sha": null, "user_notes_count": 1, "should_remove_source_branch": null, "force_remove_source_branch": false, "web_url": "https://gitlab.example.com/gitlab-org/gitlab-test/merge_requests/6432", "reference": "!6432", "references": { "short": "!6432", "relative": "!6432", "full": "gitlab-org/gitlab-test!6432" }, "time_stats": { "time_estimate": 0, "total_time_spent": 0, "human_time_estimate": null, "human_total_time_spent": null } } ] ``` ## Participants on issues[](#participants-on-issues "Permalink") 如果项目为私人项目或问题为机密,则需要提供凭据进行授权. 首选的方法是使用[个人访问令牌](../user/profile/personal_access_tokens.html) . ``` GET /projects/:id/issues/:issue_iid/participants ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `issue_iid` | integer | yes | 项目问题的内部 ID | ``` curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/5/issues/93/participants" ``` 响应示例: ``` [ { "id": 1, "name": "John Doe1", "username": "user1", "state": "active", "avatar_url": "http://www.gravatar.com/avatar/c922747a93b40d1ea88262bf1aebee62?s=80&d=identicon", "web_url": "http://localhost/user1" }, { "id": 5, "name": "John Doe5", "username": "user5", "state": "active", "avatar_url": "http://www.gravatar.com/avatar/4aea8cf834ed91844a2da4ff7ae6b491?s=80&d=identicon", "web_url": "http://localhost/user5" } ] ``` ## Comments on issues[](#comments-on-issues "Permalink") 注释是通过[notes](notes.html)资源完成的. ## Get user agent details[](#get-user-agent-details "Permalink") 仅适用于管理员. ``` GET /projects/:id/issues/:issue_iid/user_agent_detail ``` | Attribute | Type | Required | Description | | --- | --- | --- | --- | | `id` | integer/string | yes | 经过身份验证的用户拥有[的项目](README.html#namespaced-path-encoding)的 ID 或[URL 编码路径](README.html#namespaced-path-encoding) | | `issue_iid` | integer | yes | The internal ID of a project’s issue | ``` curl --header "PRIVATE-TOKEN: " "https://gitlab.example.com/api/v4/projects/5/issues/93/user_agent_detail" ``` 响应示例: ``` { "user_agent": "AppleWebKit/537.36", "ip_address": "127.0.0.1", "akismet_submitted": false } ```