When performing an JQL search with the JRJC SearchRestClient, and restricting the fields returned by the search, using the param fields of the searchJql(..) method, there are some fields that always need to be included in the provided list of field names.
The Javadoc of "@param fields" states:
Note that the following fields: summary, issuetype, created, updated, project and status are required.
And true, if not all of these fields are included, the searchJql fails when parsing the search result:
JiraRestClient jiraRestClient = ...
String jql = ...
Set<String> neededFields = new HashSet<>(Arrays.asList("summary", "issuetype"))
jiraRestClient.getSearchClient()//
.searchJql(jql, null, null, neededFields)//
.get(5, TimeUnit.SECONDS);
Exception:
Caused by: java.util.concurrent.ExecutionException: RestClientException{statusCode=Optional.absent(), errorCollections=[]}
at io.atlassian.util.concurrent.Promises$OfStage.get(Promises.java:357)
at com.atlassian.jira.rest.client.internal.async.DelegatingPromise.get(DelegatingPromise.java:106)
at at.allianz.tools.releasenotes.toc.issues.jira.JiraClient.search(JiraClient.java:114)
... 5 more
Caused by: RestClientException{statusCode=Optional.absent(), errorCollections=[]}
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$3.apply(AbstractAsynchronousRestClient.java:191)
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$3.apply(AbstractAsynchronousRestClient.java:185)
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:57)
at com.atlassian.httpclient.api.ResponsePromiseMapFunction.apply(ResponsePromiseMapFunction.java:10)
at io.atlassian.util.concurrent.Promises$OfStage.lambda$fold$4(Promises.java:332)
at io.atlassian.util.concurrent.Promises.lambda$biFunction$7(Promises.java:422)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$1.lambda$doCompleted$0(SettableFuturePromiseHttpPromiseAsyncClient.java:37)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient.runInContext(SettableFuturePromiseHttpPromiseAsyncClient.java:61)
at com.atlassian.httpclient.apache.httpcomponents.SettableFuturePromiseHttpPromiseAsyncClient$ThreadLocalDelegateRunnable.run(SettableFuturePromiseHttpPromiseAsyncClient.java:129)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.codehaus.jettison.json.JSONException: JSONObject["created"] not found.
at org.codehaus.jettison.json.JSONObject.get(JSONObject.java:360)
at com.atlassian.jira.rest.client.internal.json.IssueJsonParser.getFieldStringUnisex(IssueJsonParser.java:203)
at com.atlassian.jira.rest.client.internal.json.IssueJsonParser.parse(IssueJsonParser.java:226)
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:148)
at com.atlassian.jira.rest.client.internal.async.AbstractAsynchronousRestClient$3.apply(AbstractAsynchronousRestClient.java:189)
... 9 more
So, my question is:
Why is `SearchRestClient::searchJson(String jql, Integer maxResults, Integer startAt, Set<String> fields)` not adding those required fields by itself?
That would:
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.