As described here you can get a full list of all users using:
GET /rest/api/3/users
However, this API version is only available for cloud users.
How can we get a list of all user (active and inactive) on Data Center Jira? It is quite unbelievable that among all the different API calls one can make, this is not one of them... 😲
Heres a code snippet in C# that will fetch all jira users, with paging:
int startAt = 0;
bool isLastPage = false;
var maxResults = 1000;
var users = new List<JiraUser>();
while (!isLastPage)
{
var url = $"https://{yourjirabaseurl}/api/latest/user/search?username=.&maxResults={maxResults}&startAt={startAt}";
var request = new HttpRequestMessage(HttpMethod.Get, url);
foreach (var header in headers)
{
request.Headers.Add(header.Key, header.Value);
}
var response = await _httpClient.SendAsync(request);
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
var responseContent = JsonConvert.DeserializeObject<List<JiraUser>>(content);
if (responseContent != null)
{
users.AddRange(responseContent);
startAt += maxResults;
isLastPage = responseContent.Count < maxResults;
}
else
{
isLastPage = true;
}
}
else
{
_logger.LogError($"Failed to fetch users: {response.StatusCode}");
break;
}
}
Can always use/try /rest/api/latest/user/search?username=.&maxResults=1000
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This assumes there is a maximum of 1000 users. If there is more they will be left out.
It is also not possible to ask for more than 1000 users.
Since there is no pagination for this API call, there is no way to retrieve the rest of the users.
Therefore this does not solve the problem. Thanks for the suggestion though. I did see the same solution being mentioned in the comments elsewhere.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could always get a plugin like Better Excel. It let's you export an excel file of all users that you could then filter the data there.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I would suggest you add your vote to the ticket I linked then. At this time the API does not support your needs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.