youtrackyoutrack-api

YouTrack REST API returns only subset of all users


Since version 2018.3, YouTrack has published a new API for administrating the system. One example of a new endpoint is /api/admin/users/ which is supposed to return the collection of users in the YouTrack instance, with a wide variety of fields being available compared to the old, deprecated, API.

However, when using it, I've found that it returns only a subset of all users in the instance; in my case, it produces only 42 out of 106 users.

As a workaround, I've used the deprecated API endpoint, /rest/admin/user/ to get all users, and called the new endpoint for each of the 106 results to get the newly available detailed information, but this is rather wasteful in the number of calls required, adds a dependency on a deprecated API, is altogether pretty wonky, and doesn't appear to be the intended workflow.

So the question becomes: How does one use the new API to get all users?


Solution

  • There is a default limit for a result array which is 42. You can override it by sending /api/admin/users/?$top=<YOUR_LIMIT> , you can also send -1 to get the whole set of users (may cause performance issues).

    Additionally, you can use a combination of $top and $skip get parameters to iterate through your users.