How to fetch all users through Redmine's REST API?

I’m trying to get a complete list of users from our Redmine system using the REST API. The problem is that even when I set the limit to 200, it only returns 100 users. This is frustrating because I need the entire user database for a project I’m working on.

Does anyone know if there’s a way to bypass this limitation and retrieve all users at once? Or do I need to implement some kind of pagination to get the full list? I’ve looked through the documentation but couldn’t find a clear answer.

Any help or suggestions would be greatly appreciated. Thanks in advance!

# Example code (not actual Redmine API)
def fetch_all_users(api_key)
  users = []
  page = 1
  loop do
    response = api_call('/users', limit: 100, page: page, key: api_key)
    break if response.empty?
    users.concat(response)
    page += 1
  end
  users
end

I’ve dealt with this Redmine API limitation before, and it can be frustrating. While the 100-user limit per request is fixed, there’s a workaround using offset-based pagination that’s worked well for me.

Here’s a slightly different approach you might find useful:

def get_all_users(api_key)
  all_users = []
  offset = 0
  loop do
    chunk = api_call('/users', limit: 100, offset: offset, key: api_key)
    break if chunk.empty?
    all_users.concat(chunk)
    offset += chunk.size
    sleep(1) # Add a small delay to avoid hammering the API
  end
  all_users
end

This method adjusts the offset based on the actual number of users returned in each chunk, which can be helpful if the total user count isn’t divisible by 100. The sleep() call helps prevent potential rate limiting issues.

Remember to handle any API errors gracefully, and consider implementing some caching if you need to fetch the full user list frequently. Good luck with your project!

I’ve encountered this limitation as well. Unfortunately, Redmine’s API enforces a hard limit of 100 users per request. To retrieve the entire list, you’ll need to implement pagination via the ‘offset’ parameter.

For example, you could use this approach:

def fetch_all_users(api_key)
  all_users = []
  offset = 0
  loop do
    response = api_call('/users', limit: 100, offset: offset, key: api_key)
    break if response.empty?
    all_users.concat(response)
    offset += 100
  end
  all_users
end

This method continues to fetch users until no more results are returned. While it isn’t as efficient as one fetch, it reliably allows you to obtain the complete user list within the constraints of the API.

hey there! i’ve had this issue too. the 100 user limit is a pain :frowning: you’ll need to use pagination to get all users. try something like this:

offset = 0
all_users = []
loop do
  users = api_call('/users', limit: 100, offset: offset)
  break if users.empty?
  all_users += users
  offset += 100
end

hope that helps!