Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Create internal comment with jira java rest client?

Hi,

is it possible to create an internal comment for an issue with the java rest client? When i create it with just the comment text itself, the comment is public and visible for customers in the service desk. In the JIRA Gui there is the button "Comment internally" for that.

This is how i currently create an comment:

jiraRestClient.getIssueClient().addComment( issue.getCommentsUri(), Comment.valueOf( "My comment" ) ).claim();

 

Thanks in advance!

2 answers

import com.atlassian.jira.rest.client.api.IssueRestClient;
import com.atlassian.jira.rest.client.api.JiraRestClient;
import com.atlassian.jira.rest.client.api.SearchRestClient;
import com.atlassian.jira.rest.client.api.domain.Comment;
import com.atlassian.jira.rest.client.api.domain.SearchResult;
import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory;

import java.net.URI;
import java.net.URISyntaxException;

class Scratch {
public static void main(String[] args) throws URISyntaxException {
try(JiraRestClient jiraRestClient = new AsynchronousJiraRestClientFactory()
.createWithBasicHttpAuthentication(new URI("https://jira.example.com"), "username", "password")) {
SearchRestClient searchClient = jiraRestClient.getSearchClient();
IssueRestClient issueClient = jiraRestClient.getIssueClient();
String jql = "project = DATA ...";
SearchResult searchResult = searchClient.searchJql(jql).claim();
searchResult.getIssues().forEach(issue -> issueClient.addComment(issue.getCommentsUri(), Comment.valueOf("My comment")));
}
catch (Exception e){
System.out.println("Exception handling...");
}
}
}
0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 23, 2018

This does not help me because i'm using the java rest client and also jira on premise instead of jira cloud.

In the java rest client i have not the possibility to set properties for an comment...

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 23, 2018

Try to use PUT /rest/api/2/comment/{commentId}/properties/{propertyKey}

I am not sure which java rest client you use. But you can always use the jersey client.

I am using this library: https://marketplace.atlassian.com/apps/39474/rest-java-client-for-jira?hosting=server&tab=overview

The requests are builded by the library, so i cant modify them. 

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 23, 2018

I think if a framework does not let you do something, then you either have to ask the developers of the framework, how to do it, or find another framework. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events