Sitansu
Sitansu

Reputation: 3329

JiraRestClient search returnes no results for JQL query

I am facing issue related to Search JQL. I am using the query

(issuefunction in issuesInEpics('key = ABCD-24911') and issuetype=Feature)

In Jira it is returning some record but when I am using this query in JiraRestClient it is not working, but instead returning zero records.

It is working fine for below query :

issuefunction in issuesInEpics("resolution is not empty") and issuetype = Feature

Code Snippet:

String query="issuefunction in issuesInEpics('key = ABCD-24911') and issuetype=Feature";    
Integer resultsLength=50,startAt=0;        
JiraRestClient.getSearchClient().searchJql(query,resultsLength,startAt,null);

My Maven Dependency:

<dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-rest-java-client-api</artifactId>
        <version>4.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.atlassian.jira</groupId>
        <artifactId>jira-rest-java-client-core</artifactId>
        <version>4.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.atlassian.fugue</groupId>
        <artifactId>fugue</artifactId>
        <version>2.2.1</version>
    </dependency>
    <dependency>
    <groupId>com.atlassian.httpclient</groupId>
    <artifactId>atlassian-httpclient-spi</artifactId>
    <version>0.17.0-m01</version>
    </dependency>

Anyone please help me to find the solution.

Upvotes: 8

Views: 2074

Answers (2)

Michael Ziluck
Michael Ziluck

Reputation: 655

I think there might be a problem specific to your JIRA instance that is causing your problem. My code below is based on what Anish wrote. It compiles and runs perfectly fine, printing out the exact list of issues I expect it to display.

Maybe this helps you when you can look at two pieces of code side-by-side.

public static void main(String[] args) throws URISyntaxException {
    URI uri = new URI("https://example.com");
    JiraRestClientFactory jiraRestClientFactory = new AsynchronousJiraRestClientFactory();
    try (JiraRestClient jiraRestClient = jiraRestClientFactory.createWithBasicHttpAuthentication(uri, "email", "password")) {
        SearchRestClient searchClient = jiraRestClient.getSearchClient();
        String query = "issueFunction in issuesInEpics('key = PROJ-1234') and issuetype = Task";
        System.out.println(query);
        SearchResult result = searchClient.searchJql(query, 50, 0, null).claim();
        for (Issue issue : result.getIssues()) {
            System.out.println(issue.getKey());
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

I also tried the given JQL using a custom proxy client my company uses and the query definitely works perfectly fine. Please check your environment and JIRA logs..

Upvotes: 3

B--rian
B--rian

Reputation: 5870

If I understand https://community.atlassian.com/t5/Jira-questions/How-to-get-a-list-of-quot-issues-in-epic-quot-in-Jira/qaq-p/511549 correctly, a workaround would be to use

String query="issueFunction in linkedIssuesOf('key=ABCD-24911', 'is epic of') 
  AND issuetype=Feature";  

instead of

String query="issuefunction in issuesInEpics('key = ABCD-24911') 
  AND issuetype=Feature";  

Background: It looks like the functions IssuesInEpics() and epicsOf() have been only recently introduced to amend the functionality of linkedIssuesOf().

For more documentation, see https://confluence.atlassian.com/jirasoftwarecloud/advanced-searching-functions-reference-764478342.html

Upvotes: 0

Related Questions