Skip to main content

此版本的 GitHub Enterprise Server 已于以下日期停止服务 2024-07-09. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持

REST API 现已经过版本控制。 有关详细信息,请参阅“关于 API 版本控制”。

适用于全球公告的 REST API 终结点

使用 REST API 管理企业中的全局公告横幅。

关于公告

可以使用 REST API 管理企业中的全局公告横幅。 有关详细信息,请参阅“自定义企业的用户消息”。

Get the global announcement banner

Gets the current message and expiration date of the global announcement banner in your enterprise.

“Get the global announcement banner”的 HTTP 响应状态代码

状态代码说明
200

OK

“Get the global announcement banner”的示例代码

请求示例

get/enterprise/announcement
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ http(s)://HOSTNAME/api/v3/enterprise/announcement

Announcement banner

Status: 200
{ "announcement": "Very **important** announcement about _something_.", "expires_at": "2021-01-01T00:00:00.000+00:00", "user_dismissible": false }

Set the global announcement banner

Sets the message and expiration time for the global announcement banner in your enterprise.

“Set the global announcement banner”的参数

标头
名称, 类型, 说明
accept string

Setting to application/vnd.github+json is recommended.

正文参数
名称, 类型, 说明
announcement string or null 必须

The announcement text in GitHub Flavored Markdown. For more information about GitHub Flavored Markdown, see "Basic writing and formatting syntax."

expires_at string or null

The time at which the announcement expires. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. To set an announcement that never expires, omit this parameter, set it to null, or set it to an empty string.

“Set the global announcement banner”的 HTTP 响应状态代码

状态代码说明
200

OK

“Set the global announcement banner”的示例代码

请求示例

patch/enterprise/announcement
curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ http(s)://HOSTNAME/api/v3/enterprise/announcement \ -d '{"announcement":"Very **important** announcement about _something_.","expires_at":"2021-01-01T00:00:00.000+00:00"}'

Announcement banner

Status: 200
{ "announcement": "Very **important** announcement about _something_.", "expires_at": "2021-01-01T00:00:00.000+00:00", "user_dismissible": false }

Remove the global announcement banner

Removes the global announcement banner in your enterprise.

“Remove the global announcement banner”的 HTTP 响应状态代码

状态代码说明
204

No Content

“Remove the global announcement banner”的示例代码

请求示例

delete/enterprise/announcement
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ http(s)://HOSTNAME/api/v3/enterprise/announcement

Response

Status: 204