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

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

Find ri:userkey value using the Confluence API

Hello there,

Is there a way to use the Confluence API to receive the "ri:usekey" value?

Referring to:

Confluence Cloud REST API Developer Guide 

and:

Deprecation notice and migration guide for major changes to Confluence Cloud REST APIs to improve user privacy 

We are able to to get user information, using the "Get user" API, if I know the {accountID}, using GET of said user in advance.

https://your-domain.atlassian.net/wiki/rest/api/user?accountId={accountId} 

 

However, there are a few page macros, for example:

  • Profile Picture macro
  • User Profile macro

that when viewing the HTML source, the macro object uses the "ri:userkey" value, and not the {accountID}.

<ri:user ri:userkey="8a7f808565a1b953011234567890z" />

 

We maintain quite a large number of individual profile pages, which we deploy and maintain 100% via the Confluence API.

 

Couple of questions:

  1. Is there / will there ever be a method of finding out the {accountID} value for a user, using their name?
    1. We currently only know that we have to maintain MANUALLY, an external lookup mechanism to match a user to their Confluence accountID (for example table lookup, or, database lookup)
  2. More importantly:  is there a way to use to:
    1. Lookup the ri:userkey via API ?

 

 

Thank you in advance for you feedback & advice.

 

4 comments

I am also trying to find the solution to this problem

Like Peng Xiao likes this

I also need to be able to retrieve the user's Display Name from the ri:userkey in the User Profile macro.

It indeed looks like this is an unfortunate interaction between the GDPR migration you referenced, and the XML storage format for these macros. In any case, it's preventing me from matching a User Mention to a human-readable name.

Is there any kind of API, private or not, that can be used to match a user key to a name or account ID?

  • The official API appears to have all mentions of a "user key" carefully stripped out, probably because of aforementioned GDPR migration.
  • I tried the "rest/api/search/user" endpoint, but couldn't find a CQL query that allows for searching by the old-fashioned user key.
  • There's an interesting "rest/experimental/cql/pdcleaner" endpoint, but I never managed to get it to actually return anything.

I have the same issue. Really need the `ri:user ri:userkey` to generate some pages :/

 

Edit:
Well, it turns out, you can reference it using username, which can be accountId.

<ac:link>
<ri:user ri:username="8a7f808565a1b953011234567890z"/>

</ac:link>

I've tested it on profile picture macro and it works!

 

Source: https://community.atlassian.com/t5/Confluence-questions/User-mention-Macro-REST-API/qaq-p/1037118


Edit2:
To get accountID you can use this API call (where org is your organization name):

https://org.atlassian.net/wiki/rest/api/search/user

With CQL query (https://developer.atlassian.com/server/confluence/advanced-searching-using-cql/), fullname used as example

cql = user.fullname~"surname"

So the full query will look like this:

https://org.atlassian.net/wiki/rest/api/search/user?cql=user.fullname~%22surname%22

 

Like Vaidik Kapoor likes this

Confirming that this works. I was able it generate pages using this way.

Unfortunately this does not work for the reverse case though. When confluence generates the html for a user being mentioned on the page, it will use the userkey (as per the original post in this ticket).

There is still no way to look up the userkey and convert it to an accountId, as far as I am aware.

Like Bing Wu likes this

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Confluence Cloud

🎨 Add some visual life to your templates

Hi Atlassian Community, My name is Avni Barman, and I am a Product Manager on the Confluence Cloud team. Based on feedback from you, we are giving admins more power to create templates that a...

155 views 1 7
Read article

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