Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

I want to make api call to JIRA from my small java app to get issue details

I want to make api call to JIRA from my small java app to get issue details and below are the few questions and points:

1) My Company JIRA runs on->  https://<companyname>
2) Domain name as mentioned having not Jira
3) I have access to this JIRA tool using my user cred set username and password given to me


Now, I tried 

Way 1:

String issueKey="SSK-91";
final URI jiraServerUri = new URI("https://<name>");
final JiraRestClient restClient = new AsynchronousJiraRestClientFactory().createWithBasicHttpAuthentication(jiraServerUri, "", "Developer@123");

Promise<Issue> issuePromise = restClient.getIssueClient().getIssue(issueKey);


Way 2:

URI jiraServerUri1 = URI.create("https://<name>");

AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();

BasicHttpAuthenticationHandler auth = new BasicHttpAuthenticationHandler("", "Developer@123");
JiraRestClient restClient1 = factory.create(jiraServerUri1, (AuthenticationHandler) auth);
IssueRestClient issueClient1 = restClient1.getIssueClient();
Promise<Issue> issue=issueClient1.getIssue("SSK-91");

Both of these ways, I am not getting anything, I mean ended up with exception logs in console:

2022-08-19 13:56:47.133 ERROR 26912 --- [nio-8090-exec-8] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.util.concurrent.ExecutionException: RestClientException{statusCode=Optional.of(401), errorCollections=[]}] with root cause

org.codehaus.jettison.json.JSONException: A JSONObject text must begin with '{' at character 1 of Basic authentication with passwords is deprecated. For more information, see:

at org.codehaus.jettison.json.JSONTokener.syntaxError( ~[jettison-1.1.jar:1.1]
at org.codehaus.jettison.json.JSONObject.<init>( ~[jettison-1.1.jar:1.1]
at org.codehaus.jettison.json.JSONObject.<init>( ~[jettison-1.1.jar:1.1]
at ~[jira-rest-java-client-core-5.2.1.jar:na]
at$2.apply( ~[jira-rest-java-client-core-5.2.1.jar:na]
at$2.apply( ~[jira-rest-java-client-core-5.2.1.jar:na]
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply( ~[atlassian-httpclient-api-2.0.0.jar:na]
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply( ~[atlassian-httpclient-api-2.0.0.jar:na]

1 comment

Please provide me some info as I couldn't follow the available docs!
1) Pre-requisites like permissions in jira tool and are there any different cred set to make API calls or something
2) How do I confirm my tool is JIRA cloud or JIRA server
3) domain name not having JIRA in it, instead it is https://<name>


req: I want to create a small java app, from which I want to make API call to JIRA to get issue worklogs for the provided users!


Log in or Sign up to comment