Fetching all projects in Jira

We are developing a forge app and would like to have a multi select dropdown to list all the projects in Jira instance?

We checked the APIs and this API: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-projects/#api-rest-api-3-project-search-get, provides only 50 projects at one go, and since we are developing with forge, we need to consider the 25 sec. limit. If my instance has 5000 projects, I would require 100 API calls for it which could not get complete in 25 seconds. We store the ids of selected projects in the storage API.

The workaround to solve this, which we have used is, to fetch first 50 projects and show in list along with selected ones. The issue with this is if we have lot of selected projects as well, we need to do multiple API calls.

Like if we have already selected 170 projects.

When we open the configuration page of the app, first we do API call to storage API and find all the previously selected projects. Now we would need to do 4 calls to https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-projects/#api-rest-api-3-project-search-get with comma separated project ids. Once done, we add this in dropdown and then do a call to get first 50 projects and show it as well. The first 4 calls is to ensure if any project is deleted or archived it is not shown now.

This limitation of 50 makes it complex and increases the API calls as well.

Is there any solution to this?

Hello @AnishJain

This question has been asked many, many, many times. The ‘solution’ is to use the REST API’s pagination feature to get the projects in batches, exactly as documented, then concatenate the results in your code. The REST API results limits are there for a reason and you just have to deal with them.

Essentially, any drop-down list that contains 5,000 entries is essentially a BAD IDEA in terms of a UI design in the first place Make the app more specific in what it displays to / asks from the user and make the content of the drop-down list relevant only to that topic.

1 Like