Jira API to tag user in Comment

Pravin August 16, 2021

Hi 
I am able to add comment to issue in Jira through API  but i am struggling to mention/tag user in that comment i am using below API 

curl -D- -u admin:adminxyz-X POST --data '{"body": {"type": "mention","attrs": { "id": "xyz","text": "hi @XYZ "}}}' -H "Content-type: application/json" https://myjira-prod.com/rest/api/2/issue/Test-123/comment

 

i am getting below error 

 

{"errorMessages":["Can not deserialize instance of java.lang.String out of START_OBJECT token\n at [Source: org.apache.catalina.connector.CoyoteInputStream@6851c17a; line: 1, column: 2] (through reference chain: com.atlassian.jira.issue.fields.rest.json.beans.CommentJsonBean[\"body\"])"]}+



 

2 answers

1 vote
Anton Plebanovich June 28, 2022

Just to clarify, in practive it looks like: [~accountid:5c6b8ee0e1bcdf6294d08676]. Spend some time to figure the final state

0 votes
skavatekar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 19, 2021

Hey Pravin,

Check this one,

curl D -u username:password -X POST --data '{"type":"mention","body":"hi [~user]"}' -H "Content-Type: application/json" http://myjira:8080/rest/api/2/issue/COM-1/comment

Regards,
Sunil

Paritosh Mishra September 29, 2021

Hi Sunil, I am getting the below result when using "hi [~pamishra]"  (where "pamishra" is a valid user name) to tag a user in the comment, this "User" when clicked takes me to a page saying the user does not exist.Screenshot 2021-09-24 at 3.21.07 PM.png

Like Lorna Jones likes this
Lorna Jones January 7, 2022

I also need an answer for this issue

skavatekar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 7, 2022

Make sure you have a valid user. This works and has been tested.

Paritosh Mishra January 8, 2022

Hi @Lorna Jones , found a way through this, after recent updates [~<username>] does not work in order to tag a user in JIRA comment.

Try [~accountid:{<accountid>}]. 
This worked for me.

Like # people like this
Lorna Jones January 10, 2022

thanks for replying, that is the work-around I came to the conclusion of as well! :)  - I do wish this was documented a bit better, rather than letting users stumble through forums for useful comments!

guichi zhao May 19, 2022

[~accountid:{<accountid>}] does work, is there any official documentation about this?

p_ vinay November 24, 2022

It's not work

Hamidreza.Rahimi July 30, 2023

Wrong! It still works. Probably you are formatig the string not properly. your finall string should looks like something similar (with different accountId value) to this:

[~accountid:712010:587cdfd3-1064-41ce-9637-da9a4da55666]

Like Akshay Patil likes this

Suggest an answer

Log in or Sign up to answer