Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to update one of several comments

Francis Moreau
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 22, 2020

Hi,

In this example, I want to update 2nd body comment "[COMMENT PROJET]Commentaires pour Projet", the one with the identifier "253377"

The only examples I found were single comments, not multiple ones.

"comment": {
"comments": [
{
"self": "https://oga.mycompany.fr:1027/jira/rest/api/2/issue/101377/comment/239378",
"id": "239378",
"author": {
"self": "https://oga.mycompany.fr:1027/jira/rest/api/2/user?username=administrator",
"name": "administrator",
"key": "administrator",
"emailAddress": "admin-oga@mycompany.com",
"avatarUrls": {
"48x48": "https://oga.mycompany.fr:1027/jira/secure/useravatar?avatarId=14048",
"24x24": "https://oga.mycompany.fr:1027/jira/secure/useravatar?size=small&avatarId=14048",
"16x16": "https://oga.mycompany.fr:1027/jira/secure/useravatar?size=xsmall&avatarId=14048",
"32x32": "https://oga.mycompany.fr:1027/jira/secure/useravatar?size=medium&avatarId=14048"
},
"displayName": "Administrateur OGA ",
"active": true,
"timeZone": "Europe/Paris"
},
"body": "[Ajout lien][http://collab/sites/div_doc/_layouts/OSSSearchResults.aspx?k=OSP-7076]",
"updateAuthor": {
"self": "https://oga.mycompany.fr:1027/jira/rest/api/2/user?username=administrator",
"name": "administrator",
"key": "administrator",
"emailAddress": "admin-oga@mycompany.com",
"avatarUrls": {
"48x48": "https://oga.mycompany.fr:1027/jira/secure/useravatar?avatarId=14048",
"24x24": "https://oga.mycompany.fr:1027/jira/secure/useravatar?size=small&avatarId=14048",
"16x16": "https://oga.mycompany.fr:1027/jira/secure/useravatar?size=xsmall&avatarId=14048",
"32x32": "https://oga.mycompany.fr:1027/jira/secure/useravatar?size=medium&avatarId=14048"
},
"displayName": "Administrateur OGA ",
"active": true,
"timeZone": "Europe/Paris"
},
"created": "2020-01-16T15:02:50.000+0100",
"updated": "2020-01-16T15:02:50.000+0100"
},
{
"self": "https://oga.mycompany.fr:1027/jira/rest/api/2/issue/101377/comment/253377",
"id": "253377",
"author": {
"self": "https://oga.mycompany.fr:1027/jira/rest/api/2/user?username=fmoreau",
"name": "fmoreau",
"key": "fmoreau",
"emailAddress": "francis.moreau@mycompany.com",
"avatarUrls": {
"48x48": "https://oga.mycompany.fr:1027/jira/secure/useravatar?avatarId=10242",
"24x24": "https://oga.mycompany.fr:1027/jira/secure/useravatar?size=small&avatarId=10242",
"16x16": "https://oga.mycompany.fr:1027/jira/secure/useravatar?size=xsmall&avatarId=10242",
"32x32": "https://oga.mycompany.fr:1027/jira/secure/useravatar?size=medium&avatarId=10242"
},
"displayName": "Francis MOREAU (mycompany)",
"active": true,
"timeZone": "Europe/Paris"
},
"body": "[COMMENT PROJET]Commentaires pour Projet",
"updateAuthor": {
"self": "https://oga.mycompany.fr:1027/jira/rest/api/2/user?username=fmoreau",
"name": "fmoreau",
"key": "fmoreau",
"emailAddress": "francis.moreau@mycompany.com",
"avatarUrls": {
"48x48": "https://oga.mycompany.fr:1027/jira/secure/useravatar?avatarId=10242",
"24x24": "https://oga.mycompany.fr:1027/jira/secure/useravatar?size=small&avatarId=10242",
"16x16": "https://oga.mycompany.fr:1027/jira/secure/useravatar?size=xsmall&avatarId=10242",
"32x32": "https://oga.mycompany.fr:1027/jira/secure/useravatar?size=medium&avatarId=10242"
},
"displayName": "Francis MOREAU (mycompany)",
"active": true,
"timeZone": "Europe/Paris"
},
"created": "2020-10-21T10:23:34.000+0200",
"updated": "2020-10-21T12:02:43.000+0200"
}
],
"maxResults": 2,
"total": 2,
"startAt": 0
},

 

What could be InputData in this code block?

With JiraService
.Open "PUT", Url & Query
.setRequestHeader "Content-Type", "application/json"
.setRequestHeader "User-agent", "Mozilla"
.setRequestHeader "Accept", "*/*"
.Send (InputData)
End With

 

With InputData like this one

"{ "fields" : { "comment": {"id": "253377","body": "[COMMENT PROJET]Commentaires pour Projet v2" }}}"

I have an error 400

"{"errorMessages":[],"errors":{"comment":"Field does not support update 'comment'"}}"

Thanks,

Francis MOREAU

1 answer

1 accepted

0 votes
Answer accepted
Mohamed Benziane
Community Champion
October 22, 2020

Hello @Francis Moreau 

 

Can you try with with this API :

PUT /rest/api/3/issue/{issueIdOrKey}/comment/{id}

https://docs.atlassian.com/software/jira/docs/api/REST/8.1.0/#api/2/issue-updateComment

 

{ "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget venenatis elit. Duis eu justo eget augue iaculis fermentum. Sed semper quam laoreet nisi egestas at posuere augue semper.", 
"
visibility": { "type": "role", "value": "Administrators" }
}
Francis Moreau
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 22, 2020

Thank you very much, it's working now

Like Mohamed Benziane likes this
Nishant Paraskar January 4, 2021

Can we do it on jira server script runner through ???

Suggest an answer

Log in or Sign up to answer