Forums

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

REST APIs to get a list of projects which key/name contains a string

Aiden
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 1, 2019

I know there is REST APIs to get all the projects that a user has access to (/rest/api/2/project). Is there a API that I can get all the projects which key/name starts with a certain string?

1 answer

0 votes
Klaudia Brišáková August 4, 2019

I had similar problem, so I wrote rest endpoint on my own. My endpoint gets all projects with name containing query.

@GET
@Path("/jira-project")
public Response findAllJiraProjects(@QueryParam("query") final String query) {
final List<Project> projects = projectManager.getProjectObjects();

final List<Project> result = projects.stream()
.filter(project -> project.getName().toLowerCase().contains(query.toLowerCase()))
.collect(Collectors.toList());
return Response.ok(result).build();
}

 But if there is relatively small amount of projects in Jira meybe better solution is to use Jira endpoint (/rest/api/2/project) and filter data afterwards. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events