Hi,
I am trying to create a Confluence Page using REST API and mention some existing users. Do do this I am using this macro:
<ac:link>
<ri:user ri:userkey="123456789"/>
</ac:link>
It works perfectly, but I can only get my userkey. To get others I need to ask each one particularly or query database for which I don't have access.
I tried something like this:
<ac:link>
<ri:user ri:user="user"/>
</ac:link>
but I got:
{"statusCode":500,"data":{"authorized":false,"valid":true,"errors":[],"successful":false},"message":"java.lang.RuntimeException: com.atlassian.confluence.content.render.xhtml.XhtmlException: com.atlassian.confluence.content.render.xhtml.XhtmlException: Missing required attribute: {http://atlassian.com/resource/identifier}username"}
500
Is there a way to mention a Confluence user using Rest API with only the user name (not user-key)?
Thanks.
You are writing a user macro? If so you can try this code:
<p><ac:link>
#set($userInfo = $userAccessor.getUserByName("$userEntry"))
<ri:user ri:userkey="$userInfo.key"/>
</ac:link></p>
Where $userEntry is the user name you want is selected using the @Param XXXX|type=username
Hi Bill,
Thanks for the quick response.
Unfortunately I don't have System Administrator permissions for creating new macros. I am curios if there is one already available like this one that requires the userkey.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am not aware of any. I guess it is time to bribe your admin to install user macros for you. ;-)
You could set up a local copy of Confluence where you can be an admin and do all your testing, so that your admin would just have to install the macro once it is done.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bill,
I am able to do the same thing but once I update the comment/description with this macro, no notification received by the mentioned user.
But if I use @ symbol along with the user notification email working fine. Any idea?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I suspect that the mention function is driven by a client-side script versus the server. In other words, the user macro will display a user name in a similar fashion, it won't trigger the mention script/autocomplete, driven by the shortcut the @ key.
However, all it not lost (maybe), as there is a user mention macro, so you could just use the storage format inside your user macro, and it should work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bill,
How can I get the storage format? I got the source code as below:
<ac:link>
<ri:user ri:userkey="xxxxxxx" />
</ac:link>
I have implemented this but it just shown the User. No notification.
Could you please help?
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.
Hi Orlando,
it's sufficient to use 'username' instead of 'userkey'. Confluence will transform it automatically from 'username' to 'userkey'.
<ac:link>
<ri:user ri:username="name.surname"/>
</ac:link>
Regards,
Radek
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.