I am trying to sync all users from Jira in my application but the API I am using is limited to syncing only 1000 users. I want to sync all the users rather than 1000 users. I am using Jira 9.0 and userManager getAllUsers() is deprecated. Here is my current code snippet:
UserSearchService userSearchService = ComponentAccessor.getComponent(UserSearchService.class);
UserSearchParams userSearchParams = (new UserSearchParams.Builder()).allowEmptyQuery(true).includeActive(true).includeInactive(true).maxResults(null).build();
List<ApplicationUser> appUsers = userSearchService.findUsers(null, userSearchParams);
Is there any other API or jql for this? Thanks in advance
Nope. The limit is 1,000.
Past 1,000, you have to use pagination.
Hi @sunnyape ,
Thanks for the response.
Can you please help with the paginated request. I am still struggling with the correct code.
1 Like
I was able to resolve the issue not by pagination but rather using maxResults to the total user count within the instance. Here is the updated code.
UserSearchService userSearchService = ComponentAccessor.getComponent(UserSearchService.class);
UserSearchParams userSearchParams = (new UserSearchParams.Builder()).allowEmptyQuery(true).includeActive(true).includeInactive(true).maxResults(userManager.getTotalUserCount()).build();
List<ApplicationUser> appUsers = userSearchService.findUsers(null, userSearchParams);
Hope, this helps!