项目字段的 REST API 终结点
使用 REST API 管理项目字段
List project fields for organization
List all fields for a specific organization-owned project.
“List project fields for organization”的细粒度访问令牌
此端点支持以下精细令牌类型:
精细令牌必须具有以下权限集:
- "Projects" organization permissions (read)
如果仅请求公共资源,则无需身份验证或上述权限即可使用此终结点。
“List project fields for organization”的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
project_number integer 必须The project's number. |
org string 必须The organization name. The name is not case sensitive. |
| 名称, 类型, 说明 |
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." 默认: |
before string A cursor, as given in the Link header. If specified, the query only searches for results before this cursor. For more information, see "Using pagination in the REST API." |
after string A cursor, as given in the Link header. If specified, the query only searches for results after this cursor. For more information, see "Using pagination in the REST API." |
“List project fields for organization”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
200 | OK |
304 | Not modified |
401 | Requires authentication |
403 | Forbidden |
“List project fields for organization”的示例代码
如果你通过 GHE.com 访问 GitHub,请将 api.github.com 替换为你的企业在 api.SUBDOMAIN.ghe.com 上的专用子域。
请求示例
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/projectsV2/PROJECT_NUMBER/fieldsResponse
Status: 200[
{
"id": 12345,
"node_id": "PVTF_lADOABCD1234567890",
"name": "Priority",
"data_type": "single_select",
"project_url": "https://api.github.com/projects/67890",
"options": [
{
"id": "option_1",
"name": "Low",
"color": "GREEN",
"description": "Low priority items"
},
{
"id": "option_2",
"name": "Medium",
"color": "YELLOW",
"description": "Medium priority items"
},
{
"id": "option_3",
"name": "High",
"color": "RED",
"description": "High priority items"
}
],
"created_at": "2022-04-28T12:00:00Z",
"updated_at": "2022-04-28T12:00:00Z"
},
{
"id": 67891,
"node_id": "PVTF_lADOABCD9876543210",
"name": "Status",
"data_type": "single_select",
"project_url": "https://api.github.com/projects/67890",
"options": [
{
"id": "option_4",
"name": "Todo",
"color": "GRAY",
"description": "Items to be worked on"
},
{
"id": "option_5",
"name": "In Progress",
"color": "BLUE",
"description": "Items currently being worked on"
},
{
"id": "option_6",
"name": "Done",
"color": "GREEN",
"description": "Completed items"
}
],
"created_at": "2022-04-29T10:30:00Z",
"updated_at": "2022-04-29T10:30:00Z"
},
{
"id": 24680,
"node_id": "PVTF_lADOABCD2468024680",
"name": "Team notes",
"data_type": "text",
"project_url": "https://api.github.com/projects/67890",
"created_at": "2022-05-15T08:00:00Z",
"updated_at": "2022-05-15T08:00:00Z"
},
{
"id": 13579,
"node_id": "PVTF_lADOABCD1357913579",
"name": "Story points",
"data_type": "number",
"project_url": "https://api.github.com/projects/67890",
"created_at": "2022-06-01T14:30:00Z",
"updated_at": "2022-06-01T14:30:00Z"
},
{
"id": 98765,
"node_id": "PVTF_lADOABCD9876598765",
"name": "Due date",
"data_type": "date",
"project_url": "https://api.github.com/projects/67890",
"created_at": "2022-06-10T09:15:00Z",
"updated_at": "2022-06-10T09:15:00Z"
},
{
"id": 11223,
"node_id": "PVTF_lADOABCD1122311223",
"name": "Sprint",
"data_type": "iteration",
"project_url": "https://api.github.com/projects/67890",
"configuration": {
"duration": 14,
"start_day": 1,
"iterations": [
{
"id": "iter_1",
"title": "Sprint 1",
"start_date": "2022-07-01",
"duration": 14
},
{
"id": "iter_2",
"title": "Sprint 2",
"start_date": "2022-07-15",
"duration": 14
}
]
},
"created_at": "2022-06-20T16:45:00Z",
"updated_at": "2022-06-20T16:45:00Z"
}
]Get project field for organization
Get a specific field for an organization-owned project.
“Get project field for organization”的细粒度访问令牌
此端点支持以下精细令牌类型:
精细令牌必须具有以下权限集:
- "Projects" organization permissions (read)
如果仅请求公共资源,则无需身份验证或上述权限即可使用此终结点。
“Get project field for organization”的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
project_number integer 必须The project's number. |
field_id integer 必须The unique identifier of the field. |
org string 必须The organization name. The name is not case sensitive. |
“Get project field for organization”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
200 | OK |
304 | Not modified |
401 | Requires authentication |
403 | Forbidden |
“Get project field for organization”的示例代码
如果你通过 GHE.com 访问 GitHub,请将 api.github.com 替换为你的企业在 api.SUBDOMAIN.ghe.com 上的专用子域。
请求示例
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/projectsV2/PROJECT_NUMBER/fields/FIELD_IDResponse
Status: 200{
"id": 12345,
"node_id": "PVTF_lADOABCD1234567890",
"name": "Priority",
"data_type": "single_select",
"project_url": "https://api.github.com/projects/67890",
"options": [
{
"id": "option_1",
"name": "Low",
"color": "GREEN",
"description": "Low priority items"
},
{
"id": "option_2",
"name": "Medium",
"color": "YELLOW",
"description": "Medium priority items"
},
{
"id": "option_3",
"name": "High",
"color": "RED",
"description": "High priority items"
}
],
"created_at": "2022-04-28T12:00:00Z",
"updated_at": "2022-04-28T12:00:00Z"
}List project fields for user
List all fields for a specific user-owned project.
“List project fields for user”的细粒度访问令牌
此终结点不适用于 GitHub 应用程序用户访问令牌、GitHub 应用程序安装访问令牌或细粒度个人访问令牌。
“List project fields for user”的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
project_number integer 必须The project's number. |
username string 必须The handle for the GitHub user account. |
| 名称, 类型, 说明 |
|---|
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." 默认: |
before string A cursor, as given in the Link header. If specified, the query only searches for results before this cursor. For more information, see "Using pagination in the REST API." |
after string A cursor, as given in the Link header. If specified, the query only searches for results after this cursor. For more information, see "Using pagination in the REST API." |
“List project fields for user”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
200 | OK |
304 | Not modified |
401 | Requires authentication |
403 | Forbidden |
“List project fields for user”的示例代码
如果你通过 GHE.com 访问 GitHub,请将 api.github.com 替换为你的企业在 api.SUBDOMAIN.ghe.com 上的专用子域。
请求示例
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/users/USERNAME/projectsV2/PROJECT_NUMBER/fieldsResponse
Status: 200[
{
"id": 12345,
"node_id": "PVTF_lADOABCD1234567890",
"name": "Priority",
"data_type": "single_select",
"project_url": "https://api.github.com/projects/67890",
"options": [
{
"id": "option_1",
"name": "Low",
"color": "GREEN",
"description": "Low priority items"
},
{
"id": "option_2",
"name": "Medium",
"color": "YELLOW",
"description": "Medium priority items"
},
{
"id": "option_3",
"name": "High",
"color": "RED",
"description": "High priority items"
}
],
"created_at": "2022-04-28T12:00:00Z",
"updated_at": "2022-04-28T12:00:00Z"
},
{
"id": 67891,
"node_id": "PVTF_lADOABCD9876543210",
"name": "Status",
"data_type": "single_select",
"project_url": "https://api.github.com/projects/67890",
"options": [
{
"id": "option_4",
"name": "Todo",
"color": "GRAY",
"description": "Items to be worked on"
},
{
"id": "option_5",
"name": "In Progress",
"color": "BLUE",
"description": "Items currently being worked on"
},
{
"id": "option_6",
"name": "Done",
"color": "GREEN",
"description": "Completed items"
}
],
"created_at": "2022-04-29T10:30:00Z",
"updated_at": "2022-04-29T10:30:00Z"
},
{
"id": 24680,
"node_id": "PVTF_lADOABCD2468024680",
"name": "Team notes",
"data_type": "text",
"project_url": "https://api.github.com/projects/67890",
"created_at": "2022-05-15T08:00:00Z",
"updated_at": "2022-05-15T08:00:00Z"
},
{
"id": 13579,
"node_id": "PVTF_lADOABCD1357913579",
"name": "Story points",
"data_type": "number",
"project_url": "https://api.github.com/projects/67890",
"created_at": "2022-06-01T14:30:00Z",
"updated_at": "2022-06-01T14:30:00Z"
},
{
"id": 98765,
"node_id": "PVTF_lADOABCD9876598765",
"name": "Due date",
"data_type": "date",
"project_url": "https://api.github.com/projects/67890",
"created_at": "2022-06-10T09:15:00Z",
"updated_at": "2022-06-10T09:15:00Z"
},
{
"id": 11223,
"node_id": "PVTF_lADOABCD1122311223",
"name": "Sprint",
"data_type": "iteration",
"project_url": "https://api.github.com/projects/67890",
"configuration": {
"duration": 14,
"start_day": 1,
"iterations": [
{
"id": "iter_1",
"title": "Sprint 1",
"start_date": "2022-07-01",
"duration": 14
},
{
"id": "iter_2",
"title": "Sprint 2",
"start_date": "2022-07-15",
"duration": 14
}
]
},
"created_at": "2022-06-20T16:45:00Z",
"updated_at": "2022-06-20T16:45:00Z"
}
]Get project field for user
Get a specific field for a user-owned project.
“Get project field for user”的细粒度访问令牌
此终结点不适用于 GitHub 应用程序用户访问令牌、GitHub 应用程序安装访问令牌或细粒度个人访问令牌。
“Get project field for user”的参数
| 名称, 类型, 说明 |
|---|
accept string Setting to |
| 名称, 类型, 说明 |
|---|
project_number integer 必须The project's number. |
field_id integer 必须The unique identifier of the field. |
username string 必须The handle for the GitHub user account. |
“Get project field for user”的 HTTP 响应状态代码
| 状态代码 | 说明 |
|---|---|
200 | OK |
304 | Not modified |
401 | Requires authentication |
403 | Forbidden |
“Get project field for user”的示例代码
如果你通过 GHE.com 访问 GitHub,请将 api.github.com 替换为你的企业在 api.SUBDOMAIN.ghe.com 上的专用子域。
请求示例
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/users/USERNAME/projectsV2/PROJECT_NUMBER/fields/FIELD_IDResponse
Status: 200{
"id": 12345,
"node_id": "PVTF_lADOABCD1234567890",
"name": "Priority",
"data_type": "single_select",
"project_url": "https://api.github.com/projects/67890",
"options": [
{
"id": "option_1",
"name": "Low",
"color": "GREEN",
"description": "Low priority items"
},
{
"id": "option_2",
"name": "Medium",
"color": "YELLOW",
"description": "Medium priority items"
},
{
"id": "option_3",
"name": "High",
"color": "RED",
"description": "High priority items"
}
],
"created_at": "2022-04-28T12:00:00Z",
"updated_at": "2022-04-28T12:00:00Z"
}