Hi , I am facing issue while fetching JIRA id's through JAVA using Rest API. I am using code
SearchRestClient searchClient = client.getSearchClient();
SearchResult result = searchClient.searchJql(jqlquery).claim();
and getting exception as :
RestClientException{statusCode=Optional.absent(), errorCollections=[]}
at com.atlassian.jira.rest.client.internal.async.DelegatingPromise.claim(DelegatingPromise.java:47)
Caused by: RestClientException{statusCode=Optional.absent(), errorCollections=[]}
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$3.apply(AbstractAsynchronousRestClient.java:188)
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$3.apply(AbstractAsynchronousRestClient.java:182)
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:62)
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:12)
at com.atlassian.util.concurrent.Promises$Of$3.apply(Promises.java:295)
at com.atlassian.util.concurrent.Promises$2.onSuccess(Promises.java:185)
at com.google.common.util.concurrent.Futures$4.run(Futures.java:1154)
at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:293)
at com.google.common.util.concurrent.ExecutionList$RunnableExecutorPair.execute(ExecutionList.java:150)
at com.google.common.util.concurrent.ExecutionList.execute(ExecutionList.java:135)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:185)
at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:53)
at com.atlassian.util.concurrent.Promises$Of$3.apply(Promises.java:295)
at com.atlassian.util.concurrent.Promises$2.onSuccess(Promises.java:185)
at com.google.common.util.concurrent.Futures$4.run(Futures.java:1154)
at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:293)
at com.google.common.util.concurrent.ExecutionList$RunnableExecutorPair.execute(ExecutionList.java:150)
at com.google.common.util.concurrent.ExecutionList.execute(ExecutionList.java:135)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:185)
at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:53)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$1$1.run(SettableFuturePromiseHttpPromiseAsyncClient.java:46)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateRunnable$1.run(SettableFuturePromiseHttpPromiseAsyncClient.java:197)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient.runInContext(SettableFuturePromiseHttpPromiseAsyncClient.java:90)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateRunnable.run(SettableFuturePromiseHttpPromiseAsyncClient.java:192)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.codehaus.jettison.json.JSONException: JSONObject["name"] not found.
at org.codehaus.jettison.json.JSONObject.get(JSONObject.java:369)
at org.codehaus.jettison.json.JSONObject.getString(JSONObject.java:496)
at com.atlassian.jira.rest.client.internal.json.JsonParseUtil.parseBasicUser(JsonParseUtil.java:192)
at com.atlassian.jira.rest.client.internal.json.UserJsonParser.parse(UserJsonParser.java:34)
at com.atlassian.jira.rest.client.internal.json.UserJsonParser.parse(UserJsonParser.java:31)
at com.atlassian.jira.rest.client.internal.json.IssueJsonParser.getOptionalNestedField(IssueJsonParser.java:300)
at com.atlassian.jira.rest.client.internal.json.IssueJsonParser.parse(IssueJsonParser.java:234)
at com.atlassian.jira.rest.client.internal.json.IssueJsonParser.parse(IssueJsonParser.java:88)
at com.atlassian.jira.rest.client.internal.json.GenericJsonArrayParser.parse(GenericJsonArrayParser.java:39)
at com.atlassian.jira.rest.client.internal.json.SearchResultJsonParser.parse(SearchResultJsonParser.java:40)
at com.atlassian.jira.rest.client.internal.json.SearchResultJsonParser.parse(SearchResultJsonParser.java:27)
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$1.handle(AbstractAsynchronousRestClient.java:145)
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$3.apply(AbstractAsynchronousRestClient.java:186)
... 26 more
Hello @Suraj Parwani ,
We don't have enough information to possibly be able to help and the stacktrace is not including any meaningful error message (not even the status code):
Caused by: RestClientException{statusCode=Optional.absent(), errorCollections=[]}
Therefore, in order to be able to help, we need to know:
Finally, for the future, please notice that this is not the best place to get help on development related questions. The right resources are listed in https://developer.atlassian.com/resources.
Specifically:
Cheers,
Dario
Hi,
Thanks for replying on post.
I am again attaching the exception which we catch in RestClientException which is as follows :
RestClientException{statusCode=Optional.absent(), errorCollections=[]}
at com.atlassian.jira.rest.client.internal.async.DelegatingPromise.claim(DelegatingPromise.java:47)
at com.utility.Jira.executeJQLQuery(Jira.java:51)
at com.impl.Querying.fetchJiraDetails(Querying.java:1009)
at com.impl.Querying.coreLogicToRunSuite(Querying.java:573)
at com.impl.Querying.executeAndDataAccuracy(Querying.java:402)
at com.impl.Querying.executeSuiteBasedOnUserDefinedOperation(Querying.java:244)
at com.impl.Querying.operationBeforeExecutingSuite(Querying.java:211)
at com.impl.Querying.readEnviromentDetailsAndAssign(Querying.java:194)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
at org.testng.SuiteRunner.run(SuiteRunner.java:240)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1198)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1123)
at org.testng.TestNG.run(TestNG.java:1031)
at com.impl.MainClass.main(MainClass.java:407)
Caused by: RestClientException{statusCode=Optional.absent(), errorCollections=[]}
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$3.apply(AbstractAsynchronousRestClient.java:188)
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$3.apply(AbstractAsynchronousRestClient.java:182)
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:62)
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:12)
at com.atlassian.util.concurrent.Promises$Of$3.apply(Promises.java:295)
at com.atlassian.util.concurrent.Promises$2.onSuccess(Promises.java:185)
at com.google.common.util.concurrent.Futures$4.run(Futures.java:1154)
at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:293)
at com.google.common.util.concurrent.ExecutionList$RunnableExecutorPair.execute(ExecutionList.java:150)
at com.google.common.util.concurrent.ExecutionList.execute(ExecutionList.java:135)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:185)
at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:53)
at com.atlassian.util.concurrent.Promises$Of$3.apply(Promises.java:295)
at com.atlassian.util.concurrent.Promises$2.onSuccess(Promises.java:185)
at com.google.common.util.concurrent.Futures$4.run(Futures.java:1154)
at com.google.common.util.concurrent.MoreExecutors$SameThreadExecutorService.execute(MoreExecutors.java:293)
at com.google.common.util.concurrent.ExecutionList$RunnableExecutorPair.execute(ExecutionList.java:150)
at com.google.common.util.concurrent.ExecutionList.execute(ExecutionList.java:135)
at com.google.common.util.concurrent.AbstractFuture.set(AbstractFuture.java:185)
at com.google.common.util.concurrent.SettableFuture.set(SettableFuture.java:53)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$1$1.run(SettableFuturePromiseHttpPromiseAsyncClient.java:46)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateRunnable$1.run(SettableFuturePromiseHttpPromiseAsyncClient.java:197)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient.runInContext(SettableFuturePromiseHttpPromiseAsyncClient.java:90)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateRunnable.run(SettableFuturePromiseHttpPromiseAsyncClient.java:192)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.codehaus.jettison.json.JSONException: JSONObject["name"] not found.
at org.codehaus.jettison.json.JSONObject.get(JSONObject.java:369)
at org.codehaus.jettison.json.JSONObject.getString(JSONObject.java:496)
at com.atlassian.jira.rest.client.internal.json.JsonParseUtil.parseBasicUser(JsonParseUtil.java:192)
at com.atlassian.jira.rest.client.internal.json.UserJsonParser.parse(UserJsonParser.java:34)
at com.atlassian.jira.rest.client.internal.json.UserJsonParser.parse(UserJsonParser.java:31)
at com.atlassian.jira.rest.client.internal.json.IssueJsonParser.getOptionalNestedField(IssueJsonParser.java:300)
at com.atlassian.jira.rest.client.internal.json.IssueJsonParser.parse(IssueJsonParser.java:234)
at com.atlassian.jira.rest.client.internal.json.IssueJsonParser.parse(IssueJsonParser.java:88)
at com.atlassian.jira.rest.client.internal.json.GenericJsonArrayParser.parse(GenericJsonArrayParser.java:39)
at com.atlassian.jira.rest.client.internal.json.SearchResultJsonParser.parse(SearchResultJsonParser.java:40)
at com.atlassian.jira.rest.client.internal.json.SearchResultJsonParser.parse(SearchResultJsonParser.java:27)
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$1.handle(AbstractAsynchronousRestClient.java:145)
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$3.apply(AbstractAsynchronousRestClient.java:186)
... 26 more
I thing I noticed that this exception is coming when issues are linked to epic story and whereas if 0 issues are linked to epic , this exception doesnt occurs.
Answering to your questions,
1. Is this for Jira Server or Cloud?
Ans : Cloud
2. Are you using any existing framework or if you wrote your own Java code?
Ans : We have written our code.
static String jiraUrl = "https://cleartrail.atlassian.net";
public static JiraRestClient getJiraRestClient() {
return new AsynchronousJiraRestClientFactory().createWithBasicHttpAuthentication(getJiraUri(), username, password);
}
public static URI getJiraUri() {
return URI.create(jiraUrl);
}
public static Issue getIssue(String issueKey) {
return getJiraRestClient().getIssueClient().getIssue(issueKey).claim();
}
jiraServerUri = new URI(jiraUrl);
JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
JiraRestClient client = factory.createWithBasicHttpAuthentication(jiraServerUri, username, password);
SearchRestClient searchClient = client.getSearchClient();
SearchResult result = searchClient.searchJql(jqlquery).claim();
3. What is the authentication method used?
Ans: I have attached code for the same.
4. Which REST API endpoint (I guess the search endpoint but please confirm) are you calling and what is the method used (GET, POST)?
Ans: I think its GET.
5. What is the JQL used for the search?
Ans: Working Fine JQL as stated above :
project = NEWUX AND status in ("In Progress", Open, Reopened, Resolved) AND "Epic Link" = NEWUX-20856 ORDER BY summary ASC,updated DESC
Exception in :
project = NEWUX AND status in ("In Progress", Open, Reopened, Resolved) AND "Epic Link" = NEWUX-20857 ORDER BY summary ASC,updated DESC
6. Is the same REST API request working fine outside your Java code, e.g. if you use Curl or Postman?
Ans: As some of the JQL is working fine so I think that case would also be same on postman
And sorry to add question over here, next time I will remember the correct place.
Thanks
Suraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Suraj Parwani ,
Please confirm my understanding is correct:
If the above is correct, then I need to know the following to try to reproduce the issue:
Have a nice weekend.
Dario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Thanks for your response.
Sorry ,it was my mistake, I considered we use Rest API but I have rechecked we are using JAVA API.
And yes, search works fine if no issue is linked to it.
Also adding to it we use token for authentication with the email address of the user.
I think our NEWUX is a classic project.
and last time we got an exception on Mon, 27 Apr 2020 10:21:37,509 IST.
Please provide us with the solution so that we can continue further.
Thanks
Suraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Suraj Parwani ,
In order to determine whether the issue is with Jira or with your code, can you kindly run the below REST API GET request using Curl and paste the output in here?
curl -D- -u <EMAIL_ADDRESS>:<API-TOKEN> "https://cleartrail.atlassian.net/rest/api/3/issue/search?jql=project%20%3D%20NEWUX%20AND%20status%20in%20%28%22In%20Progress%22%2C%20Open%2C%20Reopened%2C%20Resolved%29%20AND%20%22Epic%20Link%22%20%3D%20NEWUX-20857"
Replace <EMAIL_ADDRESS>, <API-TOKEN> with the appropriate data and make sure to hide/remove them (together with other sensitive data, if any) when pasting the console output in your reply.
Also, if you are able to reproduce the issue this way, let me know date time and timezone you executed this.
Cheers,
Dario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
I hope you are doing well !!
I ran curl command and here's the output -
curl -D- -u email:token "https://cleartrail.atlassian.net/rest/api/3/issue/search?jql=project%20%3D%20NEWUX%20AND%20status%20in%20%28%22In%20Progress%22%2C%20Open%2C%20Reopened%2C%20Resolved%29%20AND%20%22Epic%20Link%22%20%3D%20NEWUX-20857"
HTTP/1.1 404
Server: AtlassianProxy/1.15.8.1
Vary: Accept-Encoding
Cache-Control: no-cache, no-store, no-transform
Content-Type: application/json;charset=UTF-8
Strict-Transport-Security: max-age=315360000; includeSubDomains; preload
Date: Tue, 05 May 2020 04:24:14 GMT
ATL-TraceId: 26398a55f0030723
X-AREQUESTID: 66aad1b8-b1d6-4add-983d-aacbc3743313
X-AACCOUNTID: 557058%3A6791035f-1090-4bde-9942-7f8bc8c05121
X-XSS-Protection: 1; mode=block
Transfer-Encoding: chunked
Timing-Allow-Origin: *
X-Content-Type-Options: nosniff
Micros-Issuer: micros/edge-authenticator
Connection: keep-alive
Set-Cookie: atlassian.xsrf.token=BGDZ-WVXR-M53S-QK9R_bdd583c525a10b69e0f6277a9caa6ad8b1f7e948_lin; Path=/; Secure
Expect-CT: report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/global-proxy", enforce, max-age=86400
{"errorMessages":["Issue does not exist or you do not have permission to see it."],"errors":{}}
I am getting this while running curl command
I ran it on 5/5/20 at 9:54 AM IST
Thanks
Suraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Suraj Parwani ,
If you get 404 (page not found), most likely the authentication did not succeed.
Can you confirm that:
Cheers,
Dario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Hope you are doing great !
Answers to your question :
1. Yes, I replaces exact details which I use in API.
2. Yes the instance URL is correct .
3. Yes , I am able to login with that account and run both of the query where the first query returns 0 results and second one returns 17 results .
Thanks
Suraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Suraj Parwani ,
I can see that the authentication of the REST API call succeeded but I can also see that the user authenticated does not correspond to your email address/user account.
Can you kindly confirm you are able to run the same JQL from the UI being logged in as gaurav.pandey@ixxxxxxxxs.com ?
I am asking this since it can be the case that the account used to authenticate does not have the rights to see that project/issue.
Indeed, I get the exact same results if I run the same JQL against my instance, but that's normal since I don't have any project named NEWUX.
JQL:
project = NEWUX AND status in ("In Progress", Open, Reopened, Resolved) AND "Epic Link" = NEWUX-20857
REST API CALL:
curl -u <EMAIL-ADDRESS>:<API-TOKEN> -D- -X GET "https://<NAME>.atlassian.net/rest/api/3/issue/search?jql=project%20%3D%20NEWUX%20AND%20status%20in%20%28%22In%20Progress%22%2C%20Open%2C%20Reopened%2C%20Resolved%29%20AND%20%22Epic%20Link%22%20%3D%20NEWUX-20857"
HTTP/2 404
server: AtlassianProxy/1.15.8.1
vary: Accept-Encoding
cache-control: no-cache, no-store, no-transform
content-type: application/json;charset=UTF-8
strict-transport-security: max-age=315360000; includeSubDomains; preload
date: Wed, 13 May 2020 11:43:24 GMT
atl-traceid: 408xxxxxxxxxxxxx02
x-arequestid: bbdxxxxxxxxxxxxxxxcbb
x-aaccountid: 557xxxxxxxxxxxxxxxxxxxxxxxxxxx1f624c
x-xss-protection: 1; mode=block
timing-allow-origin: *
x-content-type-options: nosniff
micros-issuer: micros/edge-authenticator
set-cookie: atlassian.xsrf.token=BALxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxcbce248ddf1da_lin; Path=/; Secure
expect-ct: report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/global-proxy", enforce, max-age=86400
{"errorMessages":["Issue does not exist or you do not have permission to see it."],"errors":{}}
Cheers,
Dario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Answering to your questions,
Yes, we are running JQL with different user and I am able to run JQL from gaurav.pandey@ixxxxxxxxs.com where I am getting outputs as mentioned earlier also.
And the account has all rights to see the results whereas he is a team member so he has all the rights of the project.
We again ran both queries with gaurav.pandey user and got the results.
Please see to issue with API.
Regards
Suraj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Suraj Parwani ,
I am not sure I understand correctly your answer.
Are you able to run the JQL from the UI and from REST API authenticating as gaurav.pandey@ixxxxxxxxs.com or not?
Also, please paste curl output when calling the REST API endpoint providing both JQL queries as requested.
Cheers,
Dario
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.