jirajira-rest-apijira-rest-java-api

How to get comment ID via rest api in the Jira


I need to get the comment content via code or script, and I found this doc and try it, but now, the latest issue is I cannot get the comment ID. Could you please help us to get the latest comment ID or list all comment ID via task ID. Thx.

What I tried:

API: https://your-domain.atlassian.net/rest/api/2/comment/{commentId}/properties

Java code:

HttpResponse<JsonNode> response = Unirest.get("https://your-domain.atlassian.net/rest/api/2/comment/{commentId}/properties")
  .basicAuth("email@example.com", "<api_token>")
  .header("Accept", "application/json")
  .asJson();

System.out.println(response.getBody());

I have tried this api via postman, and it works.


Solution

  • You can find it from the issue id or key.

    First, get the issue's comments via:

    GET /rest/api/2/issue/{issueIdOrKey}/comment

    Then, find the comment id from here and call

    GET /rest/api/2/comment/{commentId}/properties

    Update

    The first API could get task details and then we need to use below API to get one of the comment.

    rest/api/2/issue/{issueIdOrKey}/comment/{commentId}