• 4
    • 4
    • We collect Jira Service Desk feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.

      NOTE: This suggestion is for Jira Service Management Server/Data Center. Using Jira Service Management Cloud? See the corresponding suggestion.

      Summary

      It's possible to transition a request via REST API and also to add an internal comment via REST API.

      However, it's not possible to transition and add an internal comment in the same call

      Suggestion

      Make it possible to transition and add an internal comment in the same REST API call

          Form Name

            [JSDSERVER-5034] Transition and add internal comment via REST API

            Below worked for me to transition and add internal comment

            function Add-InternalComment {
                param (
                    [string]$IssueKey,
                    [string]$Comment,
                    [string]$TransitionId = "181"  # Default transition ID
                )

                # Define the URL for the transitions endpoint
                $transitionUrl = "https://xxxxx.atlassian.net/rest/api/2/issue/$IssueKey/transitions"

                # Get the authentication headers
                $headers = Get-JiraAuthHeader

                # Prepare the body for the transition request
                $body = @{
                    update = @{
                        comment = @(
                            @{
                                add = @{
                                    body = $Comment
                                    properties = @(
                                        @{
                                            key = "sd.public.comment"
                                            value = @

            {                                     internal = $true                                 }

                                        }
                                    )
                                }
                            }
                        )
                    }
                    transition = @

            {             id = $TransitionId         }

                } | ConvertTo-Json -Depth 10 -Compress

                try

            {         # Perform the transition and add the internal comment         Write-Host "Transitioning issue $IssueKey and adding an internal comment."         Invoke-RestMethod -Uri $transitionUrl -Method Post -Headers $headers -Body $body         Write-Host "Successfully transitioned issue $IssueKey and added an internal comment."     }

            catch

            {         Write-Host "Error occurred while transitioning and commenting on issue $IssueKey : $_"         throw     }

            }

            Ahmed Hisham added a comment - Below worked for me to transition and add internal comment function Add-InternalComment {     param (         [string] $IssueKey,         [string] $Comment,         [string] $TransitionId = "181"  # Default transition ID     )     # Define the URL for the transitions endpoint     $transitionUrl = "https://xxxxx.atlassian.net/rest/api/2/issue/$IssueKey/transitions"     # Get the authentication headers     $headers = Get-JiraAuthHeader     # Prepare the body for the transition request     $body = @{         update = @{             comment = @(                 @{                     add = @{                         body = $Comment                         properties = @(                             @{                                 key = "sd.public.comment"                                 value = @ {                                     internal = $true                                 }                             }                         )                     }                 }             )         }         transition = @ {             id = $TransitionId         }     } | ConvertTo-Json -Depth 10 -Compress     try {         # Perform the transition and add the internal comment         Write-Host "Transitioning issue $IssueKey and adding an internal comment."         Invoke-RestMethod -Uri $transitionUrl -Method Post -Headers $headers -Body $body         Write-Host "Successfully transitioned issue $IssueKey and added an internal comment."     } catch {         Write-Host "Error occurred while transitioning and commenting on issue $IssueKey : $_"         throw     } }

            Jumping in here, as I'm also trying to do something similar. I am using the Jira Automation block called "Transition Issue." My workflow is configured to require a comment when transitioned between a specific status. This automation block, I'm sure it using an API call on the backend.

            As a result to use this automation block I MUST provide a comment. However, I'd like that comment to be an "internal note" on a JSM project. I've tried multiple iterations of JSON blobs using the "More Options" config of the automation block, but have yet to be able to get the comment to be an internal one.

             

            JSON Blob attempt #1

             

            {
                "update": {
                    "comment": [
                        {
                            "add": {
                                "body": "My comment body here.",
                                "public": false
                            }
                        }
                    ]
                }
            } 

             

            JSON Blob attempt #2

            {
                "update": {
                    "comment": [
                        {
                            "add": {
                                "body": "My comment body here",
                                "properties": [
                                    {
                                        "key": "sd.public.comment",
                                        "value": {
                                            "internal": true
                                        }
                                    }
                                ]
                            }
                        }
                    ]
                }
            } 

             

            Jeret Shuck added a comment - Jumping in here, as I'm also trying to do something similar. I am using the Jira Automation block called "Transition Issue." My workflow is configured to require a comment when transitioned between a specific status. This automation block, I'm sure it using an API call on the backend. As a result to use this automation block I MUST provide a comment. However, I'd like that comment to be an "internal note" on a JSM project. I've tried multiple iterations of JSON blobs using the "More Options" config of the automation block, but have yet to be able to get the comment to be an internal one.   JSON Blob attempt #1   {     "update" : {         "comment" : [             {                 "add" : {                     "body" : "My comment body here." ,                     " public " : false                 }             }         ]     } }   JSON Blob attempt #2 {     "update" : {         "comment" : [             {                 "add" : {                     "body" : "My comment body here" ,                     "properties" : [                         {                             "key" : "sd. public .comment" ,                             "value" : {                                 "internal" : true                             }                         }                     ]                 }             }         ]     } }  

            According to https://community.atlassian.com/t5/Jira-questions/add-a-comment-while-changing-issue-status-by-REST/qaq-p/590930, "You can only add a comment while transitioning by REST if you require a comment for transitioning in UI".  Maybe change the transition to require a comment first?

            James Tuttle added a comment - According to https://community.atlassian.com/t5/Jira-questions/add-a-comment-while-changing-issue-status-by-REST/qaq-p/590930 , "You can only add a comment while transitioning by REST if you require a comment for transitioning in UI".  Maybe change the transition to require a comment first?

            Michael Hawkins added a comment - - edited

            I am trying to use the "Do Transition" API https://<host>/rest/api/2/issue/<issue>/transitions

            See https://docs.atlassian.com/software/jira/docs/api/REST/8.4.2/#api/2/issue-doTransition

            For testing, I am using body:

            {
              "update": {
                "comment": [
                  {
                    "add": {
                      "body""This is a comment"
                    }
                  }
                ]
              },
              "transition": {
                "id""31"
              }

            }

            The problem is that the comment is not added to the issue. While the transition does happen.

            Michael Hawkins added a comment - - edited I am trying to use the "Do Transition" API https://<host>/rest/api/2/issue/<issue>/transitions See https://docs.atlassian.com/software/jira/docs/api/REST/8.4.2/#api/2/issue-doTransition For testing, I am using body: {    "update" : {      "comment" : [       {          "add" : {            "body" :  "This is a comment"         }       }     ]   },    "transition" : {      "id" :  "31"   } } The problem is that the comment is not added to the issue. While the transition does happen.

            Srecko Anzic added a comment - - edited

            You need to have this body, sorry for the one line formatting:
            {"body": {"type": "doc","version": 1,
            "content": [{"type": "paragraph","content": [

            {"text": "My internal comment.","type": "text"}

            ]}]},
            "properties": \\{"key": "sd.public.comment","value": {"internal": true}}
            }

            Srecko Anzic added a comment - - edited You need to have this body, sorry for the one line formatting: {"body": {"type": "doc","version": 1, "content": [{"type": "paragraph","content": [ {"text": "My internal comment.","type": "text"} ]}]}, "properties": \\{"key": "sd.public.comment","value": {"internal": true}} }

            toddler added a comment - - edited

            Hi Michael, did you try to use a Transitionscreen and having the comment on it ?

            For me this works.

             

            But still fighting to be able to set the internal comment.

            BR

            Heiko Gerlach

            NEXUS AG

            toddler added a comment - - edited Hi Michael, did you try to use a Transitionscreen and having the comment on it ? For me this works.   But still fighting to be able to set the internal comment. BR Heiko Gerlach NEXUS AG

            Any update on this? You still cannot post a comment when doing a transition using v2.

            The body is accepted, the transition happens, but the comment does not appear in the ticket.
            {
              "update": {
                "comment": [
                  {
                    "add": {
                      "body""This is a comment"
                    }
                  }
                ]
              },
              "transition": {
                "id""31"
              }
            {color:#000000}}

            Michael Hawkins added a comment - Any update on this? You still cannot post a comment when doing a transition using v2. The body is accepted, the transition happens, but the comment does not appear in the ticket. {    "update" : {      "comment" : [       {          "add" : {            "body" :  "This is a comment"         }       }     ]   },    "transition" : {      "id" :  "31"   } {color:#000000}}

            Srecko Anzic added a comment - - edited

            I am unable to add an 'Internal Comment'.
            $url = "https://XXX.atlassian.net/rest/api/2/issue/{issuekey}/comment"
            $headers = @{ "Authorization" = "Basic $encodedCreds" }
            $Body = @

            { body = "Disabled network and email accounts." public = 'false' }

            Invoke-RestMethod -Method Post -Uri $url -Headers $headers -Body (ConvertTo-Json $body).ToString() -ContentType "application/json"

            Srecko Anzic added a comment - - edited I am unable to add an 'Internal Comment'. $url = "https://XXX.atlassian.net/rest/api/2/issue/{issuekey}/comment" $headers = @{ "Authorization" = "Basic $encodedCreds" } $Body = @ { body = "Disabled network and email accounts." public = 'false' } Invoke-RestMethod -Method Post -Uri $url -Headers $headers -Body (ConvertTo-Json $body).ToString() -ContentType "application/json"

            Any update on this?

            Yvan Martin added a comment - Any update on this?

            To Add some clarity on this issue it seems the Jira API works for this whereas the Jira service desk api does not. I need to use the Jira Service desk API to make the comment internal

            GET

            "https://jiraurl.com/rest/api/2/issue/{issueIdOrKey}/transitions"  works and returns transition ids

            "https://jiraurl.com/rest/servicedeskapi/request/{issueIdOrKey}/transition" returns empty values

             

            POST

            "https://jiraurl.com/rest/api/2/issue/{issueIdOrKey}/transitions"  -works but cannot make comments internal  "public": "false", is ignored

            "https://jiraurl.com/rest/servicedeskapi/request/{issueIdOrKey}/transition" returns 400 it just a simple example json body of a relevant transition id 

            { "id": "91" }

             

             

             

             

            Tom Martin added a comment - To Add some clarity on this issue it seems the Jira API works for this whereas the Jira service desk api does not. I need to use the Jira Service desk API to make the comment internal GET "https://jiraurl.com/rest/api/2/issue/{issueIdOrKey}/transitions"  works and returns transition ids "https://jiraurl.com/rest/servicedeskapi/request/{issueIdOrKey}/transition" returns empty values   POST "https://jiraurl.com/rest/api/2/issue/{issueIdOrKey}/transitions"  -works but cannot make comments internal  "public": "false", is ignored "https://jiraurl.com/rest/servicedeskapi/request/{issueIdOrKey}/transition" returns 400 it just a simple example json body of a relevant transition id  { "id": "91" }        

              Unassigned Unassigned
              ywoo Yit Wei
              Votes:
              35 Vote for this issue
              Watchers:
              20 Start watching this issue

                Created:
                Updated: