Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do i get the issues from a filter in my java code using rest api?

Sameeksha Shetty February 23, 2020

I'm trying to get the issues in a list or collection by passing a filter through my code.

I found some examples of this using JqlQueryBuilder but I'm unable to find the maven dependency for its use. Is there another method? Or maybe by passing a jql query?

1 answer

1 accepted

0 votes
Answer accepted
DPKJ
Community Champion
February 23, 2020

@Sameeksha Shetty  Welcome to the community!

You need to use

com.atlassian.jira.bc.issue.search.SearchService

which is part of Jira plugin API (in com.atlassian.jira:jira-api)

Here is a sample using this,

Query query = "YOUR_STRING_JQL";

SearchService searchService =
ComponentAccessor.getComponent(SearchService.class);

// Here is user is user in context or user who want to access
SearchService.ParseResult parseResult = searchService.parseQuery(user, query);

if (parseResult.isValid()) {

SearchResults results = searchService.search(user, parseResult.getQuery(),
PageFilter.getUnlimitedFilter());

List<Issue> issues = results.getIssues(); //here is your desired result
}
Sameeksha Shetty February 25, 2020

Thanks a lot. Do you know which maven  dependency works for this?

DPKJ
Community Champion
February 25, 2020

@Sameeksha Shetty  As I have mentioned earlier, this is part of, com.atlassian.jira:jira-api

<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>${jira.version}</version>
<scope>provided</scope>
</dependency>
Sameeksha Shetty March 1, 2020

okay thanks :)

Suggest an answer

Log in or Sign up to answer