Add a comment and mention users using Confluence API

María Cabrera March 17, 2022

Hello, I'm trying to add a comment with a mention to some users using Confluence API.

This is the request:

{
"type": "comment",
"mode": "create",
"container":
{
"id": "pagId",
"type": "page"
},
"body": {
"storage": {
"value": "THIS S A TEST. PLEASE IGNORE THIS COMMENT.<ac:link><ri:user ri:userkey=\"userId1\"/></ac:link>, <ac:link><ri:user ri:userkey=\"userId2\"/></ac:link>, <ac:link><ri:user ri:username=\"name.surname\"/></ac:link>",
"representation": "storage"
}
}
}

 

It is working, but the users' name is "unlicensed user" and these users have a license. 
Screenshot 2022-03-17 at 11.32.14.png

1 answer

0 votes
Ivan Lima
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 17, 2022

Hi @María Cabrera, are you using the account id for the userkey? Try that instead; it should work. You can mention someone and view the storage format of the page to confirm the syntax.

<ac:link><ri:user ri:userkey="8a7f808a7******************eb330006"/></ac:link>
María Cabrera March 17, 2022

@Ivan Lima , yes, I'm using the account Id for the userkey

Ivan Lima
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 18, 2022

I tested it myself, and it turns out that userkey works, but the account id doesn't. You can get the userkey by mentioning a user on a page, publishing it, and accessing the "view storage format" settings (More actions > Advanced details > View Storage Format).

Screen Shot 2022-03-18 at 4.15.36 PM.png

I know Atlassian is deprecating username and userkey from the APIs and using the account id instead. Maybe this is yet to roll out.

Like María Cabrera likes this
María Cabrera March 21, 2022

Thank you Ivan, it's working now!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events