Tcl Jira - Issues: Update a Comment

Back to Index

Updates a comment. This example updates comment (id=10019) for the issue with key = "SCRUM-15".

Documentation: https://developers.atlassian.com/cloud/jira/platform/rest/#api-api-2-issue-issueIdOrKey-comment-id-put

CURL Command

curl --request PUT --user jira@example.com:JIRA_API_TOKEN \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '
    {
      "body": "ABC 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"
      }
    }' \
  --url 'https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15/comment/10019'

Tcl Example


load ./chilkat.dll

set rest [new_CkRest]

#  URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15/comment/10019
set bTls 1
set port 443
set bAutoReconnect 1
set success [CkRest_Connect $rest "your-domain.atlassian.net" $port $bTls $bAutoReconnect]
if {[expr $success != 1]} then {
    puts "ConnectFailReason: [CkRest_ConnectFailReason $rest]"
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    exit
}

CkRest_SetAuthBasic $rest "jira@example.com" "JIRA_API_TOKEN"

set json [new_CkJsonObject]

CkJsonObject_UpdateString $json "body" "ABC 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."
CkJsonObject_UpdateString $json "visibility.type" "role"
CkJsonObject_UpdateString $json "visibility.value" "Administrators"

CkRest_AddHeader $rest "Content-Type" "application/json"
CkRest_AddHeader $rest "Accept" "application/json"

set sbRequestBody [new_CkStringBuilder]

CkJsonObject_EmitSb $json $sbRequestBody
set sbResponseBody [new_CkStringBuilder]

set success [CkRest_FullRequestSb $rest "PUT" "/rest/api/2/issue/SCRUM-15/comment/10019" $sbRequestBody $sbResponseBody]
if {[expr $success != 1]} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkJsonObject $json
    delete_CkStringBuilder $sbRequestBody
    delete_CkStringBuilder $sbResponseBody
    exit
}

set respStatusCode [CkRest_ResponseStatusCode $rest]
if {[expr $respStatusCode >= 400]} then {
    puts "Response Status Code = $respStatusCode"
    puts "Response Header:"
    puts [CkRest_responseHeader $rest]
    puts "Response Body:"
    puts [CkStringBuilder_getAsString $sbResponseBody]
    delete_CkRest $rest
    delete_CkJsonObject $json
    delete_CkStringBuilder $sbRequestBody
    delete_CkStringBuilder $sbResponseBody
    exit
}

set jsonResponse [new_CkJsonObject]

CkJsonObject_LoadSb $jsonResponse $sbResponseBody

set self [CkJsonObject_stringOf $jsonResponse "self"]
set id [CkJsonObject_stringOf $jsonResponse "id"]
set authorSelf [CkJsonObject_stringOf $jsonResponse "author.self"]
set authorName [CkJsonObject_stringOf $jsonResponse "author.name"]
set authorKey [CkJsonObject_stringOf $jsonResponse "author.key"]
set authorAccountId [CkJsonObject_stringOf $jsonResponse "author.accountId"]
set authorEmailAddress [CkJsonObject_stringOf $jsonResponse "author.emailAddress"]
set authorAvatarUrls48x48 [CkJsonObject_stringOf $jsonResponse "author.avatarUrls.48x48"]
set authorAvatarUrls24x24 [CkJsonObject_stringOf $jsonResponse "author.avatarUrls.24x24"]
set authorAvatarUrls16x16 [CkJsonObject_stringOf $jsonResponse "author.avatarUrls.16x16"]
set authorAvatarUrls32x32 [CkJsonObject_stringOf $jsonResponse "author.avatarUrls.32x32"]
set authorDisplayName [CkJsonObject_stringOf $jsonResponse "author.displayName"]
set authorActive [CkJsonObject_BoolOf $jsonResponse "author.active"]
set authorTimeZone [CkJsonObject_stringOf $jsonResponse "author.timeZone"]
set body [CkJsonObject_stringOf $jsonResponse "body"]
set updateAuthorSelf [CkJsonObject_stringOf $jsonResponse "updateAuthor.self"]
set updateAuthorName [CkJsonObject_stringOf $jsonResponse "updateAuthor.name"]
set updateAuthorKey [CkJsonObject_stringOf $jsonResponse "updateAuthor.key"]
set updateAuthorAccountId [CkJsonObject_stringOf $jsonResponse "updateAuthor.accountId"]
set updateAuthorEmailAddress [CkJsonObject_stringOf $jsonResponse "updateAuthor.emailAddress"]
set updateAuthorAvatarUrls48x48 [CkJsonObject_stringOf $jsonResponse "updateAuthor.avatarUrls.48x48"]
set updateAuthorAvatarUrls24x24 [CkJsonObject_stringOf $jsonResponse "updateAuthor.avatarUrls.24x24"]
set updateAuthorAvatarUrls16x16 [CkJsonObject_stringOf $jsonResponse "updateAuthor.avatarUrls.16x16"]
set updateAuthorAvatarUrls32x32 [CkJsonObject_stringOf $jsonResponse "updateAuthor.avatarUrls.32x32"]
set updateAuthorDisplayName [CkJsonObject_stringOf $jsonResponse "updateAuthor.displayName"]
set updateAuthorActive [CkJsonObject_BoolOf $jsonResponse "updateAuthor.active"]
set updateAuthorTimeZone [CkJsonObject_stringOf $jsonResponse "updateAuthor.timeZone"]
set created [CkJsonObject_stringOf $jsonResponse "created"]
set updated [CkJsonObject_stringOf $jsonResponse "updated"]
set visibilityType [CkJsonObject_stringOf $jsonResponse "visibility.type"]
set visibilityValue [CkJsonObject_stringOf $jsonResponse "visibility.value"]

delete_CkRest $rest
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jsonResponse

Sample JSON Response Body

{
  "self": "https://chilkat.atlassian.net/rest/api/2/issue/10014/comment/10019",
  "id": "10019",
  "author": {
    "self": "https://chilkat.atlassian.net/rest/api/2/user?username=admin",
    "name": "admin",
    "key": "admin",
    "accountId": "557058:be8b47b5-3bc0-43f6-b6b2-2cca0de12204",
    "emailAddress": "admin@chilkatsoft.com",
    "avatarUrls": {
      "48x48": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue",
      "24x24": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=24&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D24%26noRedirect%3Dtrue",
      "16x16": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=16&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D16%26noRedirect%3Dtrue",
      "32x32": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D32%26noRedirect%3Dtrue"
    },
    "displayName": "Chilkat Admin",
    "active": true,
    "timeZone": "America/Chicago"
  },
  "body": "ABC 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.",
  "updateAuthor": {
    "self": "https://chilkat.atlassian.net/rest/api/2/user?username=admin",
    "name": "admin",
    "key": "admin",
    "accountId": "557058:be8b47b5-3bc0-43f6-b6b2-2cca0de12204",
    "emailAddress": "admin@chilkatsoft.com",
    "avatarUrls": {
      "48x48": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=48&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D48%26noRedirect%3Dtrue",
      "24x24": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=24&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D24%26noRedirect%3Dtrue",
      "16x16": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=16&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D16%26noRedirect%3Dtrue",
      "32x32": "https://avatar-cdn.atlassian.com/16d54dcc6d4bef86fd7ee62a7cf6334a?s=32&d=https%3A%2F%2Fsecure.gravatar.com%2Favatar%2F16d54dcc6d4bef86fd7ee62a7cf6334a%3Fd%3Dmm%26s%3D32%26noRedirect%3Dtrue"
    },
    "displayName": "Chilkat Admin",
    "active": true,
    "timeZone": "America/Chicago"
  },
  "created": "2018-04-14T10:14:41.741-0500",
  "updated": "2018-04-14T10:25:07.558-0500",
  "visibility": {
    "type": "role",
    "value": "Administrators"
  }
}