Working with comments

In this recipe, we will see how to manage comments on an issue.

Getting ready

Create a JIRA REST client as mentioned in the Writing Java client for REST API recipe.

How to do it...

Adding a comment on an issue using REST API is pretty easy!

  1. Retrieve the issue on which the comment needs to be added and retrieve the user who needs to make the comment:
            final Promise<Issue> issue = 
            jiraRestClient.getIssueClient().getIssue(key); 
            Issue browsedIssue = issue.get(); User jobin = 
            jiraRestClient.getUserClient().getUser("jobinkk").get();
  2. Create a Comment object using issue URI, comment text, author, time of the comment, and so on. You can optionally add visibility information as well, similar to what we have ...

Get JIRA Development Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.