Submit pull request comments¶
POST /api/v5/repos/{owner}/{repo}/pulls/{number}/comments
This endpoint submits a comment to the specified pull request. You can specify a file path and line number for a line-level comment, or choose a file-level comment; on success it returns the comment ID and comment content.
Access token support¶
- AtomGit user access tokens (AtomGit user access tokens)
Whether anonymous access is allowed¶
This endpoint does not allow anonymous access.
Request parameters¶
| Parameter | Location | Type | Required | Description |
|---|---|---|---|---|
owner |
path | string | Yes | The namespace address the repository belongs to (the address path of an organization or personal namespace) |
repo |
path | string | Yes | Repository path (path) |
number |
path | integer | Yes | Which PR, that is, the ordinal number of the PR in this repository |
access_token |
query | string | Yes | User authorization code |
Request Body:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"body": {
"description": "Comment content",
"type": "string"
},
"path": {
"description": "Relative path of the file",
"type": "string"
},
"position": {
"description": "Line number of the code",
"type": "integer"
},
"position_type": {
"description": "Comment position type: \"binary\" means a file-level comment, \"text\" means a code-line comment; defaults to \"text\", and when \"binary\" is passed, position no longer takes effect",
"type": "string",
"enum": ["binary", "text"],
"default": "text"
}
},
"required": ["body"]
}
Response parameters¶
| Field | Type | Always returned | Nullable | Description |
|---|---|---|---|---|
id |
string | Yes | No | Comment ID |
body |
string | Yes | No | Comment content |
Error response¶
This endpoint may return the following error responses. The actual error field names are as returned by the backend.
400 Parameter error
401 Unauthenticated
HTTP response status codes¶
| Status code | Description |
|---|---|
200 |
Success (OK) |
401 |
Authentication required (Requires authentication) |
404 |
The resource does not exist (Not found) |
500 |
Internal system error (Internal server error) |
Request example¶
Parameter descriptions¶
The example must be consistent with the rest of this document and can be called successfully as copied: none of the required parameters may be omitted, and the authentication method matches "Access token support". The placeholders mean the following:
<owner>is replaced with the namespace address the repository belongs to (the address path of an organization or personal namespace);<repo>with the repository path (path);<number>with which PR (the ordinal number of the PR in this repository);<token>with your AtomGit user access token.
cURL¶
curl -X POST 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>/comments?access_token=<token>' \
-H 'Content-Type: application/json' \
-d '{
"body": "Suggest changing this to asynchronous processing",
"path": "src/main/java/com/example/Service.java",
"position": 120,
"position_type": "text"
}'
JavaScript¶
// Native fetch (Node.js 18+ / browser)
const response = await fetch(
"https://api.atomgit.com/api/v5/repos/<owner>/<repo>/pulls/<number>/comments?access_token=<token>",
{
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify({
body: "Suggest changing this to asynchronous processing",
path: "src/main/java/com/example/Service.java",
position: 120,
position_type: "text",
}),
}
);
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>/comments",
params={"access_token": "<token>"},
json={
"body": "Suggest changing this to asynchronous processing",
"path": "src/main/java/com/example/Service.java",
"position": 120,
"position_type": "text",
},
timeout=10,
)
resp.raise_for_status()
print(resp.json())
Response example¶
Status code: 200
{
"id": "97219c08d421e55cfa841deca16a30f5d7269e10",
"body": "Suggest changing this to asynchronous processing"
}
Error codes¶
| Error code | Description |
|---|---|
400 |
Parameter error or the request cannot be parsed |
401 |
Unauthenticated or invalid credentials (missing/invalid access credentials) |
404 |
The requested resource does not exist |
500 |
Internal system error |
Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc