get the list of all users with confluence api - how to

mzhydenko January 9, 2019

Hi!

I tried to do smth like confluence/rest/api/user?username=a and username=* and some other cases but it shows an error

No user found with key : null

so is the key the must parameter?

and is there a wildcard  for any parameter so I could get the list of all users

or any other way I could do it?

any help would be really appreciated

4 answers

1 accepted

1 vote
Answer accepted
miikhy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 9, 2019

Hi!

The documentation mentions that a parameter is required and there is no known wildcard option. That being said, the usual trick I use is to query the confluence-users group members which list all users having access:

/rest/api/group/confluence-users/member

You can also create a group with all users even unlicensed and use the same endpoint.

Feels like a workaround but it's working well!

Hope it helps!

Cheers

mzhydenko January 9, 2019

Hi @miikhy

Thanks for your answer. I tried the exact query you sent but It returns admin user only, did I misunderstood you and there are some extra things/steps I need to do?

miikhy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 9, 2019

Hi @mzhydenko,

Have you tried adding ?limit=500 to get more results?

Also, the group name in the URL is the group you're browsing, are non-admin users members of this group? Just tried it locally and it worked well :(

Cheers

Like mzhydenko likes this
mzhydenko January 9, 2019

Thank you @miikhy!

I`ll try that and hope it`ll work for me too.

Have a nice day :)

miikhy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 9, 2019

Great!

Keep us posted!

Cheers

Nathaniel Miller December 9, 2019

This worked for me, thank you so much!

I did want to point out though that confluence-users is the default user group that gets some one access, but it could be something else if configured so. for instance, my company uses the group atlassian-users to grant access to Confluence, JIRA, and BitBucket.

Shroomy July 5, 2023

And this is why the accepted answer should not be accepted.

The suggested answer only returns licensed users, not all users.

Edit:

In fact it will return both active and disabled users. But only active users will count as licensed users. My point was that you may have users without any groups. They will not be included and there is no other way to get them.

0 votes
Shroomy August 14, 2023

FYI:

In case anyone might want to spend an extra buck on a plugin/app, I have successfully managed to export all users (also over 1000 users) using the API for Techtime User Management for Jira/Confluence.

Since it allows you to get all users you can also iterate over each user and do whatever you want with it. That is, if you know some programming of course.

 

https://marketplace.atlassian.com/apps/1215285/

https://techtime.co.nz/display/TECHTIME/User+Management+-+Retrieve+Group+Membership+using+REST+API

0 votes
Steve Suranie August 1, 2023

I thought I'd update this with my Python code as it seems the API has changed: 

You will need to have an API token to run this. You will also need to know the group name. 

def getGroupMembers(self, strGrpName):

#group/member?name={name}

strAuth = "Basic YOUR BASE64ENCODED CREDENTIALS AND TOKEN"

strURL = (f'https://xxxxxx.atlassian.net/wiki/rest/api/group/member?name={strGrpName}')

strConfHeaders = {'Authorization': strAuth, 'Content-Type': 'application/json'}

response = requests.get(strURL, headers=strConfHeaders)

if response.status_code == 200:

return {"success":True, "data":response.json()}

elif response.status_code > 200:

return {"success":False, "msg":"There was an error with your requests: \n\n" + "Status Code: " + str(response.status_code) + "\nURL: " + strURL}
 Use: 

dictMemberResults = getGroupMembers(A-GROUP-NAME)
if dictMemberResults["success"] == True:
lstUsers = dictMemberResults["data"]["results"]
for thisUser in lstUsers:
if thisUser["displayName"] == A-USER-NAME:
return thisUser
else:
print(dictMemberResults["msg"])
Shroomy September 29, 2023

Cloud or data center?

Steve Suranie October 2, 2023

Cloud. 

0 votes
Deep (TechTime Initiative Group) April 8, 2020

I know I'm a bit late to the party but you future reference. There is one more way to get a list of all users without specifying the limi by making a get request to the  following end point: 

http://localhost:1990/confluence/rest/user-management/1.0/users

This will return you all the users. I hope this helps :)  

F_ GARFAGNI April 14, 2020

Yes it helps !
It works file with Jira Server v8.5.
Thank you for this trick.

Deep (TechTime Initiative Group) April 15, 2020

I will be surprised if the end point worked for Jira as I mentioned, this endpoint is for confluence, having said that I haven't tried it for Jira. Just to reconfirm, it did work for you when you tried it for Jira and not confluence, right?  

Frank July 21, 2021

I tried that URL, but got a 401 - Unauthorized response on a server where I am not admin. Probably it is meant - as the name suggests - for user management, and that needs the user to be admin.

Deep (TechTime Initiative Group) July 22, 2021

You can only access the Users page if you are a system admin hence, it will only work if you're the admin of the instance. If you try it with the admin user, it will work. Normal users cannot access the 'Users' page in the first place.  

Shroomy July 5, 2023

For data center Confluence this returns a 500 error. There is also no official documentation on this API call.

Like Maxfield Burdge likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events