Set the branches associated with an Issue¶
PUT /api/v5/repos/{owner}/{repo}/issues/{number}/related_branches
This endpoint sets the branches associated with an Issue in the specified repository. Submit a list of branch names to complete the association, and it returns the current list of branch names associated with the Issue.
Access token support¶
- AtomGit user access token (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 path of the namespace that owns the repository (the address path of an enterprise, organization, or individual) |
repo |
path | string | Yes | Repository path (path) |
number |
path | string | Yes | Issue number (case-sensitive; no need to add the # sign) |
access_token |
query | string | Yes | User authorization code |
Request Body:
The request body is a JSON object that specifies the list of branch names to associate with the Issue.
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"branch_names": {
"description": "List of branch names",
"type": "array",
"items": {
"type": "string"
}
}
},
"required": ["branch_names"]
}
Response parameters¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
| (Response body) | string[] | Yes | No | List of branch names associated with the Issue |
Error responses¶
The following examples show the failure status codes this endpoint may return, to help callers write error-handling logic.
400 Invalid parameters
{
"error": "invalid_request",
"message": "Parameter branch_names cannot be empty",
"field": "branch_names"
}
401 Unauthenticated
Note: The specific error field names in the above error responses are subject to the actual backend response.
HTTP status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
400 |
Bad request (Bad request) |
401 |
Requires authentication (Requires authentication) |
403 |
Forbidden (Forbidden) |
404 |
Resource not found (Not found) |
Request example¶
Parameter notes¶
Placeholders in the example:
Replace
<owner>with the address path of the namespace that owns the repository (the address path of an enterprise, organization, or individual); replace<repo>with the repository path (path); replace<number>with the Issue number (case-sensitive; no need to add the # sign); replace<token>with your AtomGit user access token.
cURL¶
curl -X PUT 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/issues/<number>/related_branches?access_token=<token>' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{"branch_names": ["feature/issue-1001", "feature/issue-1002"]}'
JavaScript¶
// Native fetch (Node.js 18+ / browser)
const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/issues/<number>/related_branches?access_token=<token>", {
method: "PUT",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify({
branch_names: ["feature/issue-1001", "feature/issue-1002"],
}),
});
if (!response.ok) {
throw new Error(`Request failed: ${response.status}`);
}
const data = await response.json();
console.log(data);
Python¶
import requests
resp = requests.put(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/issues/<number>/related_branches",
params={"access_token": "<token>"},
headers={
"Content-Type": "application/json",
"Accept": "application/json",
},
json={"branch_names": ["feature/issue-1001", "feature/issue-1002"]},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Response example¶
Status code: 200
Error codes¶
| Error code | Description |
|---|---|
401 |
Unauthenticated or invalid credentials (missing or invalid access credential) |
400 |
Invalid parameters or unparsable request |
403 |
No permission to access |
404 |
Request path does not exist or resource does not exist |
429 |
Too many requests; rate limit triggered |
500 |
Internal server error |
Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc