0

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?

fuglede
  • 17,388
  • 2
  • 54
  • 99

1 Answers1

4

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.

  • Perfect, thanks! (And interesting choice of default!) Just checking: These parameters have yet to be documented yet, right? Wasn't able to find anything on it in the official docs. – fuglede Feb 03 '19 at 09:13
  • Yes, there is an issue with documentation new REST endpoints for some entities. You may see these fields for Projects, for example, https://www.jetbrains.com/help/youtrack/standalone/api-admin-projects.html `Read the Projects List` section. – Max Erekhinskiy Feb 04 '19 at 06:23
  • Gotcha, that's useful. I suppose your remark on using -1 would still have been hard to guess, but knowing that `$top` were a thing would of course have been enough to get started. – fuglede Feb 04 '19 at 08:31