-
Suggestion
-
Resolution: Unresolved
-
None
-
4
-
4
-
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
- was cloned as
-
AUTO-137 Transition and add internal comment via REST API
- Closed
- links to
Form Name |
---|
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
{ internal = $true }$body = @{
update = @{
comment = @(
@{
add = @{
body = $Comment
properties = @(
@{
key = "sd.public.comment"
value = @
}
{ id = $TransitionId })
}
}
)
}
transition = @
} | 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 }}