Update repository discussion¶
PUT /api/v5/repos/{owner}/{repo}/discuss/{number}
This endpoint updates a discussion in the specified repository. You can change the discussion title, content, and category, and it returns the complete discussion information.
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 | Namespace path of the repository (the path of an enterprise, organization, or personal address) |
repo |
path | string | Yes | Repository path (path) |
number |
path | string | Yes | Discussion number |
access_token |
query | string | Yes | User authorization code |
Request Body:
The request body is submitted as JSON and contains the following fields:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"title": {
"description": "Discussion title",
"type": "string"
},
"md_content": {
"description": "Discussion content",
"type": "string"
},
"category_name": {
"description": "Discussion category",
"type": "string"
}
},
"required": ["title", "md_content", "category_name"]
}
Response parameters¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
id |
string | Yes | No | Discussion ID |
number |
integer | Yes | No | Discussion number |
title |
string | Yes | No | Discussion title |
md_content |
string | Yes | No | Discussion content |
created_at |
string | Yes | No | Creation time |
updated_at |
string | Yes | No | Update time |
author |
object | Yes | No | Author information |
is_lock |
integer | Yes | No | Whether locked |
is_pin |
integer | Yes | No | Whether pinned |
is_category_pin |
integer | Yes | No | Whether pinned within the category |
is_closed |
integer | Yes | No | Whether closed |
is_answered |
integer | Yes | No | Whether an answer is accepted |
comment_total |
integer | Yes | No | Comment total |
category |
object | Yes | No | Category information |
author object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
author.avatar_url |
string | Yes | No | Avatar URL |
author.id |
string | Yes | No | User ID |
author.object_id |
string | Yes | No | User object ID |
author.login |
string | Yes | No | Login name |
author.name |
string | Yes | No | Username |
category object
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
category.id |
string | Yes | No | Category ID |
category.name |
string | Yes | No | Category name |
category.icon |
string | Yes | No | Category icon |
category.description |
string | Yes | No | Category description |
category.type |
integer | Yes | No | Category type |
Error response¶
The endpoint may return the following error responses (error field names follow what the backend actually returns):
400 Parameter error
401 Unauthenticated
HTTP response status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
401 |
Authentication required (Requires authentication) |
403 |
Access forbidden (Forbidden) |
404 |
Resource not found (Not found) |
Request example¶
Parameter description¶
The placeholders in the example mean:
replace
<owner>with the namespace path of the repository (the path of an enterprise, organization, or personal address); replace<repo>with the repository path (path); replace<number>with the discussion number; replace<token>with your AtomGit user access token.
cURL¶
curl -X PUT 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/discuss/<number>?access_token=<token>' \
-H 'Content-Type: application/json' \
-d '{
"title": "Discussion title",
"md_content": "Discussion content",
"category_name": "Category name"
}'
JavaScript¶
// Native fetch (Node.js 18+ / browser)
const response = await fetch(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/discuss/<number>?access_token=<token>",
{
method: "PUT",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify({
title: "Discussion title",
md_content: "Discussion content",
category_name: "Category name",
}),
}
);
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>/discuss/<number>",
params={"access_token": "<token>"},
json={
"title": "Discussion title",
"md_content": "Discussion content",
"category_name": "Category name",
},
headers={"Accept": "application/json"},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Response example¶
Status code: 200
{
"id": "121",
"number": 5,
"title": "Discussion title",
"md_content": "Discussion content",
"created_at": "2024-01-01T10:00:00+08:00",
"updated_at": "2024-01-02T10:00:00+08:00",
"author": {
"avatar_url": "https://api.atomgit.com/avatar.png",
"id": "123",
"object_id": "456",
"login": "octocat",
"name": "Octo Cat"
},
"is_lock": 0,
"is_pin": 0,
"is_category_pin": 0,
"is_closed": 0,
"is_answered": 0,
"comment_total": 3,
"category": {
"id": "789",
"name": "Category name",
"icon": "https://api.atomgit.com/icon.png",
"description": "Category description",
"type": 0
}
}
Error codes¶
| Error code | Description |
|---|---|
400 |
Parameter error or unparsable request |
401 |
Unauthenticated or invalid credentials (missing/invalid access credentials) |
404 |
Request path does not exist |
405 |
Method not supported |
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