Associate an issue with a pull request¶
POST /api/v5/repos/{owner}/{repo}/pulls/{number}/issues
This endpoint associates issues in a specified repository with a target pull request. The request must include the list of issue numbers to associate. On success, it returns information such as the number and title of each associated issue.
Access token support¶
- AtomGit user access tokens
Anonymous access¶
This endpoint does not allow anonymous access.
Request parameters¶
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
owner |
path | string | Yes | Address of the namespace the repository belongs to (the address path of the organization or individual) |
repo |
path | string | Yes | Repository path (path) |
number |
path | string | Yes | The PR number, i.e. the sequence number of the PR in this repository |
access_token |
query | string | Yes | User authorization code |
Request Body:
The request body is an array of issue numbers to associate.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "array",
"description": "List of issue numbers to associate",
"items": {
"type": "integer",
"description": "The issue number, i.e. the sequence number of the issue in this repository"
}
}
Response parameters¶
The response body is an array of issues returned after a successful association. Each array element has the following structure:
Issue object (array element)
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
id |
integer | Yes | No | Issue id |
number |
string | Yes | No | The issue number, i.e. the sequence number of the issue in this repository |
title |
string | Yes | No | Issue title |
Error responses¶
Besides the success response, callers also need to understand the failure response shape so that they can write error handling.
400 Parameter error
401 Unauthenticated
Note: The error field names are subject to what the backend actually returns.
HTTP response status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
400 |
Parameter error, or the request cannot be parsed |
401 |
Requires authentication |
403 |
Forbidden |
404 |
Request path does not exist |
500 |
Internal system error |
Request example¶
Parameter description¶
Replace
<owner>with the address of the namespace the repository belongs to (the address path of the organization or individual); replace<repo>with the repository path (path); replace<number>with the PR number, i.e. the sequence number of the PR in this repository; replace<token>with your AtomGit user access token; replace<issue_number>in the request body with the issue number to associate.
cURL¶
curl -X POST 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>/issues?access_token=<token>' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '[<issue_number>]'
JavaScript¶
// Native fetch (Node.js 18+ / browser)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>/issues?access_token=<token>", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify([<issue_number>]),
});
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.post(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>/issues",
params={"access_token": "<token>"},
headers={
"Content-Type": "application/json",
"Accept": "application/json",
},
json=[<issue_number>],
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Response example¶
Status code: 200
[
{
"id": 553397,
"number": "3",
"title": "222"
},
{
"id": 553716,
"number": "7",
"title": "123"
}
]
Error codes¶
| Error code | Description |
|---|---|
400 |
Parameter error, or the request cannot be parsed |
401 |
Unauthenticated or invalid credentials (missing or invalid access credentials) |
404 |
Request path does not exist |
405 |
Request method not supported |
429 |
Too many requests; rate limit triggered |
500 |
Internal system error |
Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc