Skip to content

Create an issue comment

POST /api/v5/repos/{owner}/{repo}/issues/{number}/comments

Creates a comment under the specified issue in the specified repository by submitting the comment content, and returns details of the new comment.

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 integer Yes Issue number
access_token query string Yes User authorization code

Request Body:

The request body is submitted as application/json and contains the comment content body (required).

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "body": {
      "description": "The contents of the comment",
      "type": "string",
      "minLength": 1
    }
  },
  "required": ["body"]
}

Response parameters

Field Type Always returned Nullable Description
id integer Yes No Comment ID
body string Yes No Comment content
user object Yes Yes Information about the commenting user
target object Yes Yes Target object the comment belongs to
created_at string No Yes Comment creation time
updated_at string No Yes Comment update time

user object

Field Type Always returned Nullable Description
user.id string Yes No User ID
user.login string Yes No Login name
user.name string Yes No Username
user.type string No Yes User type, such as User
user.avatar_url string Yes No Avatar URL
user.html_url string Yes No User homepage URL
user.member_role string No Yes Member role
user.remark string No Yes Enterprise remark name
user.events_url string No Yes Events URL
user.followers_url string No Yes Followers URL
user.following_url string No Yes Following URL
user.gists_url string No Yes Gist URL
user.organizations_url string No Yes Organizations URL
user.received_events_url string No Yes Received events URL
user.repos_url string No Yes Repository URL
user.starred_url string No Yes Starred URL
user.subscriptions_url string No Yes Subscriptions URL
user.url string No Yes User URL

target.issue object

Field Type Always returned Nullable Description
target.issue.id integer Yes No Issue ID
target.issue.title string Yes No Issue title
target.issue.number integer Yes No Issue number

Error responses

401 Unauthenticated

{
  "error": "unauthorized",
  "message": "Missing or invalid access token"
}

404 Resource not found

{
  "error": "not_found",
  "message": "The repository or issue does not exist"
}

HTTP status codes

Status code Description
200 Success (OK)
401 Requires authentication (Requires authentication)
404 Resource not found (Not found)

Request example

Parameter notes

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; replace <token> with your AtomGit user access token; replace <body> with the comment content.

cURL

curl -X POST 'https://api.atomgit.com/api/v5/repos/<owner>/<repo>/issues/<number>/comments?access_token=<token>' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -d '{
    "body": "<body>"
  }'

JavaScript

const response = await fetch("https://api.atomgit.com/api/v5/repos/<owner>/<repo>/issues/<number>/comments?access_token=<token>", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Accept": "application/json",
  },
  body: JSON.stringify({
    body: "<body>",
  }),
});

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>/issues/<number>/comments",
    params={"access_token": "<token>"},
    headers={
        "Content-Type": "application/json",
        "Accept": "application/json",
    },
    json={"body": "<body>"},
    timeout=10,
)
resp.raise_for_status()

print(resp.json())

Response example

Status code: 200

{
  "id": 271624,
  "body": "Comment content.",
  "user": {
    "avatar_url": "https://api.atomgit.com/avatar.png",
    "events_url": null,
    "followers_url": null,
    "following_url": null,
    "gists_url": null,
    "html_url": "https://api.atomgit.com/dengmengmian",
    "id": "661ce4eab470b1430d456154",
    "login": "dengmengmian",
    "member_role": null,
    "name": "Ma Fan_",
    "organizations_url": null,
    "received_events_url": null,
    "remark": null,
    "repos_url": null,
    "starred_url": null,
    "subscriptions_url": null,
    "type": null,
    "url": null
  },
  "target": {
    "issue": {
      "id": 152134,
      "title": "",
      "number": 1
    }
  },
  "created_at": null,
  "updated_at": null
}

Markdown source: View on AtomGit·Content from the open-source project gitcode-dev/atomgit-api-doc