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

Santosh Varma
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 21, 2022

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>.atlassian.net/jira
2) Domain name as mentioned having .atlassian.net 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>.atlassian.net");
final JiraRestClient restClient = new AsynchronousJiraRestClientFactory().createWithBasicHttpAuthentication(jiraServerUri, "spotthori@p.net", "Developer@123");

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

 

Way 2:


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

AsynchronousJiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();

BasicHttpAuthenticationHandler auth = new BasicHttpAuthenticationHandler("spotthori@p.net", "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: https://developer.atlassian.com/cloud/confluence/deprecation-notice-basic-auth/

at org.codehaus.jettison.json.JSONTokener.syntaxError(JSONTokener.java:439) ~[jettison-1.1.jar:1.1]
at org.codehaus.jettison.json.JSONObject.<init>(JSONObject.java:169) ~[jettison-1.1.jar:1.1]
at org.codehaus.jettison.json.JSONObject.<init>(JSONObject.java:266) ~[jettison-1.1.jar:1.1]
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient.extractErrors(AbstractAsynchronousRestClient.java:212) ~[jira-rest-java-client-core-5.2.1.jar:na]
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$2.apply(AbstractAsynchronousRestClient.java:175) ~[jira-rest-java-client-core-5.2.1.jar:na]
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$2.apply(AbstractAsynchronousRestClient.java:170) ~[jira-rest-java-client-core-5.2.1.jar:na]
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:49) ~[atlassian-httpclient-api-2.0.0.jar:na]
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:10) ~[atlassian-httpclient-api-2.0.0.jar:na]

1 comment

Comment

Log in or Sign up to comment
Santosh Varma
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 21, 2022

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>.atlassian.net/

 

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!

TAGS
AUG Leaders

Atlassian Community Events