How can I add a comment to a Jira Issue via the REST API while also mentioning the reporter?

Christian Ludwig January 25, 2023

I'm trying to write a request in postman to add a comment to a Jira issue while also mentioning the reporter without knowing who the reporter of said issue is.

So far, this is my request URL:

https://{{server-name}}/rest/api/latest/issue/{{issue-key}}/comment

and I've tried the following bodies:

{

    "body": "[~accountId:{{reporter.accountId}}] this is a test comment"

}

 

{

    "body": "[~accountid:{{issue.reporter.displayName}}] this is a test comment"

}
{

    "body": "[~accountId:{{reporter.displayName}}] this is a test comment"

}

 

based on various other documentations/community help articles I've found.

However, all of these examples just come into my Jira issue as plain text (where the reporter is not resolving to actually mentioning the reporter).

4 answers

0 votes
Tomer Ben Arye July 22, 2024

POST   https://XYZ.atlassian.net/rest/api/3/issue/DPDV-8151/comment

 

{
"body": {
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "This high priority ticket was not updated for 10 days."
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "mention",
"attrs": {
"id": "712020:f0f2e610-2376-424d-9ba7-169a956cf6e7"
}
},
{
"type": "text",
"text": ", "
},
{
"type": "mention",
"attrs": {
"id": "712020:f0f2e610-2376-424d-9ba7-169a956cf6e7"
}
},
{
"type": "text",
"text": ","
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Please share an update."
}
]
}
],
"version": 1
}
}

 

Vimal Negi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 22, 2024

Its not adding comments, its just returning existing comments

 

 

Tomer Ben Arye July 22, 2024

this is what is working for me.

note to use POST, and not change the Account Id for your users.

 

 

0 votes
Vimal Negi
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 22, 2024

I am trying to add comment via following api

curl --location '{domain}.atlassian.net/rest/api/latest/issue/{ticketId}/comment' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
"body": "This is a comment added via curl."
}'
but its not adding comment, its just returning comments.
0 votes
Tomer Ben Arye June 10, 2024

POST > https://XYZ.atlassian.net/rest/api/3/issue/KEY/comment

 

The below:

Reporter <@{{1.reporter.accountId}}> or assignee <@{{1.assignee.accountId}}>

FYI - this case was not updated for a while.

 

is translated into:

{
"body": {
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "Reporter "
},
{
"type": "mention",
"attrs": {
"id": "62f60645c1b3a10ac3acf642"
}
},
{
"type": "text",
"text": " or assignee "
},
{
"type": "mention",
"attrs": {
"id": "62f60645c1b3a10ac3acf642"
}
}
]
},
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": "FYI - this case was not updated for a while."
}
]
},

 

0 votes
Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 25, 2023

Hi @Christian Ludwig

You cannot combine these two events in one API call.

When you are using the POST call to

https://{{server-name}}/rest/api/latest/issue/{{issue-key}}/comment

This is API call for adding the comments to the ticket only and ignores other data.

For updating the reporter, you should be using the PUT call to

https://{{server-name}}/rest/api/latest/issue/{{issue-key}}

and provide the following data in the 'Body' section:


{


    "fields": {

        "reporter": {

            "name""name of the reporter",

            "emailAddress""email address",

            "displayName""Full name"

        }

    }

}
Hope this helps.
Thanks,
Vamsi
Christian Ludwig January 25, 2023

Hello,

Thank you for the information, but updating the reporter of the issue is not in-scope of this question, I merely need to mention the current reporter of the issue in a comment without knowing any of the other details of the user who is the reporter alongside my comment text.

Prathamesh Shetye1
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 13, 2023

Hi @Christian Ludwig , have you sitting on any solution  now

Suggest an answer

Log in or Sign up to answer