跳至主要内容
REST API 现在已版本化。 更多信息,请参阅“关于 API 版本控制”。

团队讨论的 REST API 端点

使用 REST API 获取、创建、编辑和删除团队页面上的讨论帖子。

团队讨论和团队讨论评论端点将于 2023 年 11 月 28 日停止使用,转而使用 GitHub 讨论。有关 GitHub 讨论的更多信息,请参阅“GitHub 讨论文档”。

列出讨论

列出团队页面上的所有讨论。

注意

您还可以使用路由GET /organizations/{org_id}/team/{team_id}/discussions通过org_idteam_id指定团队。

OAuth 应用令牌和个人访问令牌(经典版)需要read:discussion作用域才能使用此端点。

"列出讨论"的参数

请求头
名称,类型,描述
accept 字符串

建议设置为application/vnd.github+json

路径参数
名称,类型,描述
org 字符串 必需

组织名称。名称不区分大小写。

team_slug 字符串 必需

团队名称的slug。

查询参数
名称,类型,描述
direction 字符串

排序结果的方向。

默认值:desc

可以是:ascdesc

per_page 整数

每页结果数(最大 100)。更多信息,请参阅“REST API 中使用分页”。

默认值:30

page 整数

要获取的结果页码。更多信息,请参阅“REST API 中使用分页”。

默认值:1

pinned 字符串

仅限已固定讨论的筛选器

"列出讨论"的 HTTP 响应状态码

状态码描述
200

OK

"列出讨论"的代码示例

请求示例

get/orgs/{org}/teams/{team_slug}/discussions
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/teams/TEAM_SLUG/discussions

响应

状态:200
[ { "author": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "body": "Hi! This is an area for us to collaborate as a team.", "body_html": "<p>Hi! This is an area for us to collaborate as a team</p>", "body_version": "0d495416a700fb06133c612575d92bfb", "comments_count": 0, "comments_url": "https://api.github.com/teams/2343027/discussions/1/comments", "created_at": "2018-01-25T18:56:31Z", "last_edited_at": null, "html_url": "https://github.com/orgs/github/teams/justice-league/discussions/1", "node_id": "MDE0OlRlYW1EaXNjdXNzaW9uMQ==", "number": 1, "pinned": false, "private": false, "team_url": "https://api.github.com/teams/2343027", "title": "Our first team post", "updated_at": "2018-01-25T18:56:31Z", "url": "https://api.github.com/teams/2343027/discussions/1", "reactions": { "url": "https://api.github.com/teams/2343027/discussions/1/reactions", "total_count": 5, "+1": 3, "-1": 1, "laugh": 0, "confused": 0, "heart": 1, "hooray": 0, "eyes": 1, "rocket": 1 } } ]

创建讨论

在团队页面上创建一个新的讨论帖子。

此端点会触发通知。使用此端点过快地创建内容可能会导致二级速率限制。更多信息,请参阅“API 的速率限制”和“使用 REST API 的最佳实践”。

注意

您还可以使用路由POST /organizations/{org_id}/team/{team_id}/discussions通过org_idteam_id指定团队。

OAuth 应用令牌和个人访问令牌(经典版)需要write:discussion作用域才能使用此端点。

"创建讨论"的参数

请求头
名称,类型,描述
accept 字符串

建议设置为application/vnd.github+json

路径参数
名称,类型,描述
org 字符串 必需

组织名称。名称不区分大小写。

team_slug 字符串 必需

团队名称的slug。

正文参数
名称,类型,描述
title 字符串 必需

讨论帖子的标题。

body 字符串 必需

讨论帖子的正文文本。

private 布尔值

私有帖子仅对团队成员、组织所有者和团队维护者可见。公开帖子对组织的所有成员可见。设置为true以创建私有帖子。

默认值:false

"创建讨论"的 HTTP 响应状态码

状态码描述
201

已创建

"创建讨论"的代码示例

请求示例

post/orgs/{org}/teams/{team_slug}/discussions
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/teams/TEAM_SLUG/discussions \ -d '{"title":"Our first team post","body":"Hi! This is an area for us to collaborate as a team."}'

响应

状态:201
{ "author": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "body": "嗨!这是一个团队协作的区域。", "body_html": "<p>嗨!这是一个团队协作的区域</p>", "body_version": "0d495416a700fb06133c612575d92bfb", "comments_count": 0, "comments_url": "https://api.github.com/teams/2343027/discussions/1/comments", "created_at": "2018-01-25T18:56:31Z", "last_edited_at": null, "html_url": "https://github.com/orgs/github/teams/justice-league/discussions/1", "node_id": "MDE0OlRlYW1EaXNjdXNzaW9uMQ==", "number": 1, "pinned": false, "private": false, "team_url": "https://api.github.com/teams/2343027", "title": "我们的第一个团队帖子", "updated_at": "2018-01-25T18:56:31Z", "url": "https://api.github.com/teams/2343027/discussions/1", "reactions": { "url": "https://api.github.com/teams/2343027/discussions/1/reactions", "total_count": 5, "+1": 3, "-1": 1, "laugh": 0, "confused": 0, "heart": 1, "hooray": 0, "eyes": 1, "rocket": 1 } }

获取讨论

在团队页面上获取特定讨论。

注意

您也可以使用路由GET /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}通过org_idteam_id指定团队。

OAuth 应用令牌和个人访问令牌(经典版)需要read:discussion作用域才能使用此端点。

"获取讨论"的参数

请求头
名称,类型,描述
accept 字符串

建议设置为application/vnd.github+json

路径参数
名称,类型,描述
org 字符串 必需

组织名称。名称不区分大小写。

team_slug 字符串 必需

团队名称的slug。

discussion_number 整数 必填

标识讨论的编号。

"获取讨论"的HTTP响应状态码

状态码描述
200

OK

"获取讨论"的代码示例

请求示例

get/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/teams/TEAM_SLUG/discussions/DISCUSSION_NUMBER

响应

状态:200
{ "author": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "body": "嗨!这是一个团队协作的区域。", "body_html": "<p>嗨!这是一个团队协作的区域</p>", "body_version": "0d495416a700fb06133c612575d92bfb", "comments_count": 0, "comments_url": "https://api.github.com/teams/2343027/discussions/1/comments", "created_at": "2018-01-25T18:56:31Z", "last_edited_at": null, "html_url": "https://github.com/orgs/github/teams/justice-league/discussions/1", "node_id": "MDE0OlRlYW1EaXNjdXNzaW9uMQ==", "number": 1, "pinned": false, "private": false, "team_url": "https://api.github.com/teams/2343027", "title": "我们的第一个团队帖子", "updated_at": "2018-01-25T18:56:31Z", "url": "https://api.github.com/teams/2343027/discussions/1", "reactions": { "url": "https://api.github.com/teams/2343027/discussions/1/reactions", "total_count": 5, "+1": 3, "-1": 1, "laugh": 0, "confused": 0, "heart": 1, "hooray": 0, "eyes": 1, "rocket": 1 } }

更新讨论

编辑讨论帖子的标题和正文文本。只有您提供的参数会被更新。

注意

您也可以使用路由PATCH /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}通过org_idteam_id指定团队。

OAuth 应用令牌和个人访问令牌(经典版)需要write:discussion作用域才能使用此端点。

"更新讨论"的参数

请求头
名称,类型,描述
accept 字符串

建议设置为application/vnd.github+json

路径参数
名称,类型,描述
org 字符串 必需

组织名称。名称不区分大小写。

team_slug 字符串 必需

团队名称的slug。

discussion_number 整数 必填

标识讨论的编号。

正文参数
名称,类型,描述
title 字符串

讨论帖子的标题。

body 字符串

讨论帖子的正文文本。

"更新讨论"的HTTP响应状态码

状态码描述
200

OK

"更新讨论"的代码示例

请求示例

patch/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}
curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/teams/TEAM_SLUG/discussions/DISCUSSION_NUMBER \ -d '{"title":"欢迎来到我们的第一个团队帖子"}'

响应

状态:200
{ "author": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "body": "嗨!这是一个团队协作的区域。", "body_html": "<p>嗨!这是一个团队协作的区域</p>", "body_version": "0d495416a700fb06133c612575d92bfb", "comments_count": 1, "comments_url": "https://api.github.com/teams/2343027/discussions/1/comments", "created_at": "2018-01-25T18:56:31Z", "last_edited_at": "2018-01-26T18:22:20Z", "html_url": "https://github.com/orgs/github/teams/justice-league/discussions/1", "node_id": "MDE0OlRlYW1EaXNjdXNzaW9uMQ==", "number": 1, "pinned": false, "private": false, "team_url": "https://api.github.com/teams/2343027", "title": "欢迎来到我们的第一个团队帖子", "updated_at": "2018-01-26T18:22:20Z", "url": "https://api.github.com/teams/2343027/discussions/1", "reactions": { "url": "https://api.github.com/teams/2343027/discussions/1/reactions", "total_count": 5, "+1": 3, "-1": 1, "laugh": 0, "confused": 0, "heart": 1, "hooray": 0, "eyes": 1, "rocket": 1 } }

删除讨论

从团队页面删除讨论。

注意

您也可以使用路由DELETE /organizations/{org_id}/team/{team_id}/discussions/{discussion_number}通过org_idteam_id指定团队。

OAuth 应用令牌和个人访问令牌(经典版)需要write:discussion作用域才能使用此端点。

"删除讨论"的参数

请求头
名称,类型,描述
accept 字符串

建议设置为application/vnd.github+json

路径参数
名称,类型,描述
org 字符串 必需

组织名称。名称不区分大小写。

team_slug 字符串 必需

团队名称的slug。

discussion_number 整数 必填

标识讨论的编号。

"删除讨论"的HTTP响应状态码

状态码描述
204

无内容

"删除讨论"的代码示例

请求示例

delete/orgs/{org}/teams/{team_slug}/discussions/{discussion_number}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/teams/TEAM_SLUG/discussions/DISCUSSION_NUMBER

响应

状态:204

列出讨论(旧版)

警告

端点关闭通知:此端点路由即将关闭,并将从团队API中移除。我们建议您将现有代码迁移到新的列出讨论端点。

列出团队页面上的所有讨论。

OAuth 应用令牌和个人访问令牌(经典版)需要read:discussion作用域才能使用此端点。

"列出讨论(旧版)"的参数

请求头
名称,类型,描述
accept 字符串

建议设置为application/vnd.github+json

路径参数
名称,类型,描述
team_id 整数 必填

团队的唯一标识符。

查询参数
名称,类型,描述
direction 字符串

排序结果的方向。

默认值:desc

可以是:ascdesc

per_page 整数

每页结果数(最大 100)。更多信息,请参阅“REST API 中使用分页”。

默认值:30

page 整数

要获取的结果页码。更多信息,请参阅“REST API 中使用分页”。

默认值:1

"列出讨论(旧版)"的HTTP响应状态码

状态码描述
200

OK

"列出讨论(旧版)"的代码示例

请求示例

get/teams/{team_id}/discussions
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/teams/TEAM_ID/discussions

响应

状态:200
[ { "author": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "body": "Hi! This is an area for us to collaborate as a team.", "body_html": "<p>Hi! This is an area for us to collaborate as a team</p>", "body_version": "0d495416a700fb06133c612575d92bfb", "comments_count": 0, "comments_url": "https://api.github.com/teams/2343027/discussions/1/comments", "created_at": "2018-01-25T18:56:31Z", "last_edited_at": null, "html_url": "https://github.com/orgs/github/teams/justice-league/discussions/1", "node_id": "MDE0OlRlYW1EaXNjdXNzaW9uMQ==", "number": 1, "pinned": false, "private": false, "team_url": "https://api.github.com/teams/2343027", "title": "Our first team post", "updated_at": "2018-01-25T18:56:31Z", "url": "https://api.github.com/teams/2343027/discussions/1", "reactions": { "url": "https://api.github.com/teams/2343027/discussions/1/reactions", "total_count": 5, "+1": 3, "-1": 1, "laugh": 0, "confused": 0, "heart": 1, "hooray": 0, "eyes": 1, "rocket": 1 } } ]

创建讨论(旧版)

警告

端点关闭通知:此端点路由即将关闭,并将从团队API中移除。我们建议您将现有代码迁移到新的创建讨论端点。

在团队页面上创建一个新的讨论帖子。

此端点会触发通知。使用此端点过快地创建内容可能会导致二级速率限制。更多信息,请参阅“API 的速率限制”和“使用 REST API 的最佳实践”。

OAuth 应用令牌和个人访问令牌(经典版)需要write:discussion作用域才能使用此端点。

"创建讨论(旧版)"的参数

请求头
名称,类型,描述
accept 字符串

建议设置为application/vnd.github+json

路径参数
名称,类型,描述
team_id 整数 必填

团队的唯一标识符。

正文参数
名称,类型,描述
title 字符串 必需

讨论帖子的标题。

body 字符串 必需

讨论帖子的正文文本。

private 布尔值

私有帖子仅对团队成员、组织所有者和团队维护者可见。公开帖子对组织的所有成员可见。设置为true以创建私有帖子。

默认值:false

"创建讨论(旧版)"的HTTP响应状态码

状态码描述
201

已创建

"创建讨论(旧版)"的代码示例

请求示例

post/teams/{team_id}/discussions
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/teams/TEAM_ID/discussions \ -d '{"title":"我们的第一个团队帖子","body":"嗨!这是一个团队协作的区域。"}'

响应

状态:201
{ "author": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "body": "嗨!这是一个团队协作的区域。", "body_html": "<p>嗨!这是一个团队协作的区域</p>", "body_version": "0d495416a700fb06133c612575d92bfb", "comments_count": 0, "comments_url": "https://api.github.com/teams/2343027/discussions/1/comments", "created_at": "2018-01-25T18:56:31Z", "last_edited_at": null, "html_url": "https://github.com/orgs/github/teams/justice-league/discussions/1", "node_id": "MDE0OlRlYW1EaXNjdXNzaW9uMQ==", "number": 1, "pinned": false, "private": false, "team_url": "https://api.github.com/teams/2343027", "title": "我们的第一个团队帖子", "updated_at": "2018-01-25T18:56:31Z", "url": "https://api.github.com/teams/2343027/discussions/1", "reactions": { "url": "https://api.github.com/teams/2343027/discussions/1/reactions", "total_count": 5, "+1": 3, "-1": 1, "laugh": 0, "confused": 0, "heart": 1, "hooray": 0, "eyes": 1, "rocket": 1 } }

获取讨论(旧版)

警告

端点关闭通知:此端点路由即将关闭,并将从团队API中移除。我们建议您将现有代码迁移到新的获取讨论端点。

在团队页面上获取特定讨论。

OAuth 应用令牌和个人访问令牌(经典版)需要read:discussion作用域才能使用此端点。

"获取讨论(旧版)"的参数

请求头
名称,类型,描述
accept 字符串

建议设置为application/vnd.github+json

路径参数
名称,类型,描述
team_id 整数 必填

团队的唯一标识符。

discussion_number 整数 必填

标识讨论的编号。

"获取讨论(旧版)"的HTTP响应状态码

状态码描述
200

OK

"获取讨论(旧版)"的代码示例

请求示例

get/teams/{team_id}/discussions/{discussion_number}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/teams/TEAM_ID/discussions/DISCUSSION_NUMBER

响应

状态:200
{ "author": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "body": "嗨!这是一个团队协作的区域。", "body_html": "<p>嗨!这是一个团队协作的区域</p>", "body_version": "0d495416a700fb06133c612575d92bfb", "comments_count": 0, "comments_url": "https://api.github.com/teams/2343027/discussions/1/comments", "created_at": "2018-01-25T18:56:31Z", "last_edited_at": null, "html_url": "https://github.com/orgs/github/teams/justice-league/discussions/1", "node_id": "MDE0OlRlYW1EaXNjdXNzaW9uMQ==", "number": 1, "pinned": false, "private": false, "team_url": "https://api.github.com/teams/2343027", "title": "我们的第一个团队帖子", "updated_at": "2018-01-25T18:56:31Z", "url": "https://api.github.com/teams/2343027/discussions/1", "reactions": { "url": "https://api.github.com/teams/2343027/discussions/1/reactions", "total_count": 5, "+1": 3, "-1": 1, "laugh": 0, "confused": 0, "heart": 1, "hooray": 0, "eyes": 1, "rocket": 1 } }

更新讨论(旧版)

警告

端点关闭通知:此端点路由即将关闭,并将从团队API中移除。我们建议您将现有代码迁移到新的更新讨论端点。

编辑讨论帖子的标题和正文文本。只有您提供的参数会被更新。

OAuth 应用令牌和个人访问令牌(经典版)需要write:discussion作用域才能使用此端点。

"更新讨论(旧版)"的参数

请求头
名称,类型,描述
accept 字符串

建议设置为application/vnd.github+json

路径参数
名称,类型,描述
team_id 整数 必填

团队的唯一标识符。

discussion_number 整数 必填

标识讨论的编号。

正文参数
名称,类型,描述
title 字符串

讨论帖子的标题。

body 字符串

讨论帖子的正文文本。

"更新讨论(旧版)"的HTTP响应状态码

状态码描述
200

OK

"更新讨论(旧版)"的代码示例

请求示例

patch/teams/{team_id}/discussions/{discussion_number}
curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/teams/TEAM_ID/discussions/DISCUSSION_NUMBER \ -d '{"title":"欢迎来到我们的第一个团队帖子"}'

响应

状态:200
{ "author": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "body": "嗨!这是一个团队协作的区域。", "body_html": "<p>嗨!这是一个团队协作的区域</p>", "body_version": "0d495416a700fb06133c612575d92bfb", "comments_count": 1, "comments_url": "https://api.github.com/teams/2343027/discussions/1/comments", "created_at": "2018-01-25T18:56:31Z", "last_edited_at": "2018-01-26T18:22:20Z", "html_url": "https://github.com/orgs/github/teams/justice-league/discussions/1", "node_id": "MDE0OlRlYW1EaXNjdXNzaW9uMQ==", "number": 1, "pinned": false, "private": false, "team_url": "https://api.github.com/teams/2343027", "title": "欢迎来到我们的第一个团队帖子", "updated_at": "2018-01-26T18:22:20Z", "url": "https://api.github.com/teams/2343027/discussions/1", "reactions": { "url": "https://api.github.com/teams/2343027/discussions/1/reactions", "total_count": 5, "+1": 3, "-1": 1, "laugh": 0, "confused": 0, "heart": 1, "hooray": 0, "eyes": 1, "rocket": 1 } }

删除讨论(旧版)

警告

端点关闭通知:此端点路由即将关闭,并将从团队API中移除。我们建议您将现有代码迁移到新的删除讨论端点。

从团队页面删除讨论。

OAuth 应用令牌和个人访问令牌(经典版)需要write:discussion作用域才能使用此端点。

"删除讨论(旧版)"的参数

请求头
名称,类型,描述
accept 字符串

建议设置为application/vnd.github+json

路径参数
名称,类型,描述
team_id 整数 必填

团队的唯一标识符。

discussion_number 整数 必填

标识讨论的编号。

"删除讨论(旧版)"的HTTP响应状态码

状态码描述
204

无内容

"删除讨论(旧版)"的代码示例

请求示例

delete/teams/{team_id}/discussions/{discussion_number}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/teams/TEAM_ID/discussions/DISCUSSION_NUMBER

响应

状态:204