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
}
}
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 }}