Help us learn about your current experience with the documentation. Take the survey.

项目 issue boards API

  • Tier: Free, Premium, Ultimate
  • Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated

每次对 issue boards 的 API 调用都必须经过身份验证。

如果用户不是私有项目的成员,对该项目的 GET 请求将返回 404 状态码。

列出项目的 issue boards

列出指定项目中的 issue boards。

GET /projects/:id/boards
属性 类型 必需 描述
id integer/string 项目的 ID 或 URL 编码路径
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/boards"

示例响应:

[
  {
    "id" : 1,
    "name": "board1",
    "hide_backlog_list": false,
    "hide_closed_list": false,
    "project": {
      "id": 5,
      "name": "Diaspora Project Site",
      "name_with_namespace": "Diaspora / Diaspora Project Site",
      "path": "diaspora-project-site",
      "path_with_namespace": "diaspora/diaspora-project-site",
      "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git",
      "web_url": "http://example.com/diaspora/diaspora-project-site"
    },
    "milestone":   {
      "id": 12,
      "title": "10.0"
    },
    "lists" : [
      {
        "id" : 1,
        "label" : {
          "name" : "Testing",
          "color" : "#F0AD4E",
          "description" : null
        },
        "position" : 1,
        "max_issue_count": 0,
        "max_issue_weight": 0,
        "limit_metric": null
      },
      {
        "id" : 2,
        "label" : {
          "name" : "Ready",
          "color" : "#FF0000",
          "description" : null
        },
        "position" : 2,
        "max_issue_count": 0,
        "max_issue_weight": 0,
        "limit_metric":  null
      },
      {
        "id" : 3,
        "label" : {
          "name" : "Production",
          "color" : "#FF5F00",
          "description" : null
        },
        "position" : 3,
        "max_issue_count": 0,
        "max_issue_weight": 0,
        "limit_metric":  null
      }
    ]
  }
]

项目中没有激活或存在的 board 时的另一个示例响应:

[]

显示单个 issue board

获取单个项目 issue board。

GET /projects/:id/boards/:board_id
属性 类型 必需 描述
id integer/string 项目的 ID 或 URL 编码路径
board_id integer board 的 ID。
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/boards/1"

示例响应:

  {
    "id": 1,
    "name": "project issue board",
    "hide_backlog_list": false,
    "hide_closed_list": false,
    "project": {
      "id": 5,
      "name": "Diaspora Project Site",
      "name_with_namespace": "Diaspora / Diaspora Project Site",
      "path": "diaspora-project-site",
      "path_with_namespace": "diaspora/diaspora-project-site",
      "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git",
      "web_url": "http://example.com/diaspora/diaspora-project-site"
    },
    "milestone":   {
      "id": 12,
      "title": "10.0"
    },
    "lists" : [
      {
        "id" : 1,
        "label" : {
          "name" : "Testing",
          "color" : "#F0AD4E",
          "description" : null
        },
        "position" : 1,
        "max_issue_count": 0,
        "max_issue_weight": 0,
        "limit_metric":  null
      },
      {
        "id" : 2,
        "label" : {
          "name" : "Ready",
          "color" : "#FF0000",
          "description" : null
        },
        "position" : 2,
        "max_issue_count": 0,
        "max_issue_weight": 0,
        "limit_metric":  null
      },
      {
        "id" : 3,
        "label" : {
          "name" : "Production",
          "color" : "#FF5F00",
          "description" : null
        },
        "position" : 3,
        "max_issue_count": 0,
        "max_issue_weight": 0,
        "limit_metric":  null
      }
    ]
  }

创建 issue board

创建项目 issue board。

POST /projects/:id/boards
属性 类型 必需 描述
id integer/string 项目的 ID 或 URL 编码路径
name string 新 board 的名称。
curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/boards?name=newboard"

示例响应:

  {
    "id": 1,
    "name": "newboard",
    "hide_backlog_list": false,
    "hide_closed_list": false,
    "project": {
      "id": 5,
      "name": "Diaspora Project Site",
      "name_with_namespace": "Diaspora / Diaspora Project Site",
      "path": "diaspora-project-site",
      "path_with_namespace": "diaspora/diaspora-project-site",
      "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git",
      "web_url": "http://example.com/diaspora/diaspora-project-site"
    },
    "lists" : [],
    "group": null,
    "milestone": null,
    "assignee" : null,
    "labels" : [],
    "weight" : null
  }

更新 issue board

更新项目 issue board。

PUT /projects/:id/boards/:board_id
属性 类型 必需 描述
id integer/string 项目的 ID 或 URL 编码路径
board_id integer board 的 ID。
name string board 的新名称。
hide_backlog_list boolean 隐藏“待处理”列表。
hide_closed_list boolean 隐藏“已关闭”列表。
assignee_id integer board 应该限定的指派人。仅限 Premium 和 Ultimate 版本。
milestone_id integer board 应该限定的里程碑。仅限 Premium 和 Ultimate 版本。
labels string board 应该限定的标签名称的逗号分隔列表。仅限 Premium 和 Ultimate 版本。
weight integer board 应该限定的权重范围(0 到 9)。仅限 Premium 和 Ultimate 版本。
curl --request PUT \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/boards/1?name=new_name&milestone_id=43&assignee_id=1&labels=Doing&weight=4"

示例响应:

  {
    "id": 1,
    "name": "new_name",
    "hide_backlog_list": false,
    "hide_closed_list": false,
    "project": {
      "id": 5,
      "name": "Diaspora Project Site",
      "name_with_namespace": "Diaspora / Diaspora Project Site",
      "path": "diaspora-project-site",
      "path_with_namespace": "diaspora/diaspora-project-site",
      "created_at": "2018-07-03T05:48:49.982Z",
      "default_branch": null,
      "tag_list": [], //deprecated, use `topics` instead
      "topics": [],
      "ssh_url_to_repo": "ssh://user@example.com/diaspora/diaspora-project-site.git",
      "http_url_to_repo": "http://example.com/diaspora/diaspora-project-site.git",
      "web_url": "http://example.com/diaspora/diaspora-project-site",
      "readme_url": null,
      "avatar_url": null,
      "star_count": 0,
      "forks_count": 0,
      "last_activity_at": "2018-07-03T05:48:49.982Z"
    },
    "lists": [],
    "group": null,
    "milestone": {
      "id": 43,
      "iid": 1,
      "project_id": 15,
      "title": "Milestone 1",
      "description": "Milestone 1 desc",
      "state": "active",
      "created_at": "2018-07-03T06:36:42.618Z",
      "updated_at": "2018-07-03T06:36:42.618Z",
      "due_date": null,
      "start_date": null,
      "web_url": "http://example.com/root/board1/milestones/1"
    },
    "assignee": {
      "id": 1,
      "name": "Administrator",
      "username": "root",
      "state": "active",
      "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon",
      "web_url": "http://example.com/root"
    },
    "labels": [{
      "id": 10,
      "name": "Doing",
      "color": "#5CB85C",
      "description": null
    }],
    "weight": 4
  }

删除 issue board

删除项目 issue board。

DELETE /projects/:id/boards/:board_id
属性 类型 必需 描述
id integer/string 项目的 ID 或 URL 编码路径
board_id integer board 的 ID。
curl --request DELETE \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/boards/1"

列出项目 issue board 中的 board lists

获取 board 的 lists 列表。 不包括 openclosed 列表。

GET /projects/:id/boards/:board_id/lists
属性 类型 必需 描述
id integer/string 项目的 ID 或 URL 编码路径
board_id integer board 的 ID。
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/boards/1/lists"

示例响应:

[
  {
    "id" : 1,
    "label" : {
      "name" : "Testing",
      "color" : "#F0AD4E",
      "description" : null
    },
    "position" : 1,
    "max_issue_count": 0,
    "max_issue_weight": 0,
    "limit_metric":  null
  },
  {
    "id" : 2,
    "label" : {
      "name" : "Ready",
      "color" : "#FF0000",
      "description" : null
    },
    "position" : 2,
    "max_issue_count": 0,
    "max_issue_weight": 0,
    "limit_metric":  null
  },
  {
    "id" : 3,
    "label" : {
      "name" : "Production",
      "color" : "#FF5F00",
      "description" : null
    },
    "position" : 3,
    "max_issue_count": 0,
    "max_issue_weight": 0,
    "limit_metric":  null
  }
]

显示单个 board list

获取单个 board list。

GET /projects/:id/boards/:board_id/lists/:list_id
属性 类型 必需 描述
id integer/string 项目的 ID 或 URL 编码路径
board_id integer board 的 ID。
list_id integer board list 的 ID。
curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/boards/1/lists/1"

示例响应:

{
  "id" : 1,
  "label" : {
    "name" : "Testing",
    "color" : "#F0AD4E",
    "description" : null
  },
  "position" : 1,
  "max_issue_count": 0,
  "max_issue_weight": 0,
  "limit_metric":  null
}

创建 board list

创建新的 issue board list。

POST /projects/:id/boards/:board_id/lists
属性 类型 必需 描述
id integer/string 项目的 ID 或 URL 编码路径
board_id integer board 的 ID。
label_id integer 标签的 ID。
assignee_id integer 用户的 ID。仅限 Premium 和 Ultimate 版本。
milestone_id integer 里程碑的 ID。仅限 Premium 和 Ultimate 版本。
iteration_id integer 迭代的 ID。仅限 Premium 和 Ultimate 版本。

Label、assignee 和 milestone 参数是互斥的,即一个请求中只接受其中一个参数。 查看 issue board 文档 以获取有关每种 list 类型所需许可的更多信息。

curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/boards/1/lists?label_id=5"

示例响应:

{
  "id" : 1,
  "label" : {
    "name" : "Testing",
    "color" : "#F0AD4E",
    "description" : null
  },
  "position" : 1,
  "max_issue_count": 0,
  "max_issue_weight": 0,
  "limit_metric":  null
}

对 board 中的 list 重新排序

更新现有的 issue board list。此调用用于更改 list 的位置。

PUT /projects/:id/boards/:board_id/lists/:list_id
属性 类型 必需 描述
id integer/string 项目的 ID 或 URL 编码路径
board_id integer board 的 ID。
list_id integer board list 的 ID。
position integer list 的位置。
curl --request PUT \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/boards/1/lists/1?position=2"

示例响应:

{
  "id" : 1,
  "label" : {
    "name" : "Testing",
    "color" : "#F0AD4E",
    "description" : null
  },
  "position" : 1,
  "max_issue_count": 0,
  "max_issue_weight": 0,
  "limit_metric":  null
}

从 board 中删除 board list

仅适用于管理员和项目所有者。删除 board list。

DELETE /projects/:id/boards/:board_id/lists/:list_id
属性 类型 必需 描述
id integer/string 项目的 ID 或 URL 编码路径
board_id integer board 的 ID。
list_id integer board list 的 ID。
curl --request DELETE \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/projects/5/boards/1/lists/1"