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

Rest API v3 Add Mention to Comment

Edited

I can successfully add a comment to an issue through the rest api, v3.  I am now trying to include a @Mention to a new comment.  I have tried @username, [~username], ~username, and [@username] to no avail.  Is there anyway to include a mention on a comment though the rest api?  I am currently using my own credentials to authenticate the api, I do have permission to create @Mentions.

2 answers

1 accepted

4 votes
Answer accepted

Hi @Jim Gruszczynski ,

If I understand correctly you can successfully add a comment using the REST API v3 endpoint /rest/api/3/issue/{issueIdOrKey}/comment but you are unable to add user mentions in the body of the comment.

If my understanding is correct, then looking at the documentation for /rest/api/3/issue/{issueIdOrKey}/comment I can read:

body

anything

The comment text in Atlassian Document Format.

 

If you open the Atlassian Document Format (ADF) page, on the left hand side menu, you can see a section named Node - mention that shows below example for adding a user mention in ADF:

{
  "type": "mention",
  "attrs": {
    "id": "ABCDE-ABCDE-ABCDE-ABCDE",
    "text": "@Bradley Ayers",
    "userType": "APP"
  }
}

 

I am pasting below all the useful links for your reference. Please review them, try to add the user mention using ADF and let us know if this works as expected:

 

Cheers,
Dario

Thank you very much @Dario B  this helped and I now have @mentions added to the comments.  Is there a way to get the email notifications to also be sent when the comment with a mention is added?

 

Thanks

Jim Gruszczynski

Dario B Atlassian Team Nov 01, 2019

You are very welcome @Jim Gruszczynski ,

If the answer helped please remember to accept it so that the thread will be marked as answered.

 

Then, for the rest, can you kindly provide more details on what you mean with:

 Is there a way to get the email notifications to also be sent when the comment with a mention is added?

The expected behavior is that users will receive notifications if they are mentioned in a comment. Please see below post for some more details:

 

Cheers,
Dario

Thank you for your quick reply.  When in the JIRA Software web site, when a user adds a comment with a @mention to another user, the other user will receive and email that they were mentioned in a comment.  Using the resources you pointed me at I was able to get the mention to work, but no emails were received by the mentioned users.

 

Thanks,

Jim  

@Dario B disregard the mentions not sending notifications, that is working, it did not notify my account when I added a mention to myself.  This seems reasonable.

 

Thanks Jim

@Jim Gruszczynski ,

Nice to know this is working!

Also, you can actually configure Jira to also send notifications for your own changes. As mentioned in the Configuring email notifications documentation page this is something you can actually set in your user profile: 

Jira's default setting is to not notify users of their own changes. This can be changed on a per user basis via their profile preferences.

 

For more details please see:

 

Cheers,
Dario

@Dario B Thanks for the details. This is preciously what i was looking for. Only issue is instead of accountid if this could take email id, that would have been much simpler to code

Like Dario B likes this

Alternate solution:

URI- https://<domain-name>/rest/api/3/issue/{issueKey}/comment

request body- 

{    

"body": "[~accountid:5d9d467e0d44fc0dca5413e7] <your comment>"

}

Like Dario B likes this

I was looking for a solution for use with jira-python, and this did the trick. Thanks!

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across their  Jira Cloud instance.  ...

779 views 17 21
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