Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get user information from Confluence REST API? Edited

I am trying to get user details like their name, email, phone, about me, department and position.

I am getting only following as response and no expandable properties.

URL - "/rest/api/user?username=sample"

Response

{"type":"known","username":"sample","userKey":"2edfc034541014edfc2c9ba06b8","profilePicture":{"path":"/images/icons/profilepics/default.png","width":48,"height":48,"isDefault":true},"displayName":"Sample, User","_links":{"base":"https://confluence.com","context":"","self":"https://confluence.com/rest/experimental/user?key=2edfc034541014edfc2c9ba06b8"}}

 

PS - I have modified to JSON details above to hide personal details.

2 answers

Hi Ashwini,

I'm fairly familiar with the Confluence API and I'm pretty sure that there is no way to get the information that you require via the REST API. Only name and e-mail should be available, but unfortunately phone, about me, department, and position are not accessible.

Hi Stephen,
Can you please share how to get the user's email address.
https://docs.atlassian.com/confluence/REST/6.2.1/#user-getUser

What all is expadable while making the request?

Hi Arjun,

I stand corrected. It does seem possible to get the details using the new /rest/user API endpoint. Here is the usage:

https://<confluence_url>/<context_path, if there is one>/rest/api/user?username=<username>&expand=details.personal,details.business

details.personal contains phone, website, and e-mail, and details.business contains position, department, and location.

Like Stan Ry likes this

Hi Stephen,

I also want to get the email address via REST, but it's missing.

That's what I got for:

GET /rest/api/user?username=myusername&expand=details.personal,details.business

{
  "type": "known",
  "username": "myusername",
  "userKey": "myuserkey",
  "profilePicture": {
    "path": "/download/attachments...",
    "width": 48,
    "height": 48,
    "isDefault": false
  },
  "displayName": "myDisplayName",
  "_links": {
    "base": "baseURL",
    "context": "",
    "self": "..."
  }
}

We are using the external LDAP user directory. Confluence Version 6.2.1. 

Thanks for your help!

Like Stan Ry likes this

It appears that the expansions are not available for Confluence Server yet; I tested on Cloud and thought that it would be the same, but apparently the products are developing at a different pace.

An alternative to be able to get the e-mail address:

https://<confluence_url>/rest/prototype/1/user/non-system/myusername

The result should be in displayableEmail.

Like Stan Ry likes this

@Stephen Deutsch 

Hi Stephen, could you please elaborate on using properties? How do I know what properties I can pass in the expand parametner of a specific API?

For example, how did you figure it out that the details.personal and details.business properties are available for expansion?

Is the /prototype/1/user/non-system/{username} API the only one that shows emails for the user? So there is no way to collect user names in emails in a single run, correct?

One has to collect all users by using /rest/api/group/{groupName}/member and then retrieve emails for each specific user, right?

Thank you.

To know what you can expand, do an API call and look under the "_expandable" key. For more information, look at this documentation: https://docs.atlassian.com/atlassian-confluence/REST/6.6.0/
under "How to use expansion in the REST APIs"

On Confluence Cloud, /rest/api/user returns the e-mail address, but on server, it seems that it's not available except in that older call (this may change in 7.0).

Like Stan Ry likes this

 

@Stephen Deutsch, thank you for support!

Consider the /rest/content API. 

 Provided example reads as follows:

Example request URI(s):
http://example.com/rest/api/content?spaceKey=TST&title=Cheese&expand=space,body.view,version,container

 The given response example however says:

 

version": {
        "by": {
            "type": "known",
            "username": "username",
            "userKey": "",
            "displayName": "Full Name",
            "_expandable": {
                "status": ""
            }
       }}

 

I am not seeing there none of these 'space', 'body.view', and 'version' expand options. Is it because the response has been already expanded? So the only way to further expand on 'version' would be to pass 'version.status' in expand parameter? Correct?

Note that there should be several _expandable entries in the response. This particular expandable section is for version, so version can be expanded to "version.status", but later in the response you should see other expandable fields. It's possible that the example response is truncated.

And yes, for version, the only further expansion would be status, so instead of "version" you would put "version.status" in the expand parameter of your request.

In recent versions of Confluence Server, I use three endpoints to get all information on a user:

GET rest/api/user?username=<username>

GET rest/mobile/1.0/profile/<username>

POST rpc/json-rpc/confluenceservice-v2/getUserByName

  • JSON Body: [<username>]

Thank you!

Second endpoint is what I was looking for. ;)

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

What do you think is the most *delightful* Confluence feature? Comment for a prize!

- Create your own custom emoji 🔥 - "Shake for Feedback" on mobile 📱 - An endless supply of GIFs via GIPHY 🤩 Is there anything quite as nice as a pleasant surprise? Comment below with what...

408 views 23 8
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you