PureBasic 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'

PureBasic Example

IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkRest.pb"

Procedure ChilkatExample()

    rest.i = CkRest::ckCreate()
    If rest.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    ;  URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15/comment/10019
    bTls.i = 1
    port.i = 443
    bAutoReconnect.i = 1
    success = CkRest::ckConnect(rest,"your-domain.atlassian.net",port,bTls,bAutoReconnect)
    If success <> 1
        Debug "ConnectFailReason: " + Str(CkRest::ckConnectFailReason(rest))
        Debug CkRest::ckLastErrorText(rest)
        CkRest::ckDispose(rest)
        ProcedureReturn
    EndIf

    CkRest::ckSetAuthBasic(rest,"jira@example.com","JIRA_API_TOKEN")

    json.i = CkJsonObject::ckCreate()
    If json.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckUpdateString(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::ckUpdateString(json,"visibility.type","role")
    CkJsonObject::ckUpdateString(json,"visibility.value","Administrators")

    CkRest::ckAddHeader(rest,"Content-Type","application/json")
    CkRest::ckAddHeader(rest,"Accept","application/json")

    sbRequestBody.i = CkStringBuilder::ckCreate()
    If sbRequestBody.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckEmitSb(json,sbRequestBody)
    sbResponseBody.i = CkStringBuilder::ckCreate()
    If sbResponseBody.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success = CkRest::ckFullRequestSb(rest,"PUT","/rest/api/2/issue/SCRUM-15/comment/10019",sbRequestBody,sbResponseBody)
    If success <> 1
        Debug CkRest::ckLastErrorText(rest)
        CkRest::ckDispose(rest)
        CkJsonObject::ckDispose(json)
        CkStringBuilder::ckDispose(sbRequestBody)
        CkStringBuilder::ckDispose(sbResponseBody)
        ProcedureReturn
    EndIf

    respStatusCode.i = CkRest::ckResponseStatusCode(rest)
    If respStatusCode >= 400
        Debug "Response Status Code = " + Str(respStatusCode)
        Debug "Response Header:"
        Debug CkRest::ckResponseHeader(rest)
        Debug "Response Body:"
        Debug CkStringBuilder::ckGetAsString(sbResponseBody)
        CkRest::ckDispose(rest)
        CkJsonObject::ckDispose(json)
        CkStringBuilder::ckDispose(sbRequestBody)
        CkStringBuilder::ckDispose(sbResponseBody)
        ProcedureReturn
    EndIf

    jsonResponse.i = CkJsonObject::ckCreate()
    If jsonResponse.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckLoadSb(jsonResponse,sbResponseBody)

    self.s
    id.s
    authorSelf.s
    authorName.s
    authorKey.s
    authorAccountId.s
    authorEmailAddress.s
    authorAvatarUrls48x48.s
    authorAvatarUrls24x24.s
    authorAvatarUrls16x16.s
    authorAvatarUrls32x32.s
    authorDisplayName.s
    authorActive.i
    authorTimeZone.s
    body.s
    updateAuthorSelf.s
    updateAuthorName.s
    updateAuthorKey.s
    updateAuthorAccountId.s
    updateAuthorEmailAddress.s
    updateAuthorAvatarUrls48x48.s
    updateAuthorAvatarUrls24x24.s
    updateAuthorAvatarUrls16x16.s
    updateAuthorAvatarUrls32x32.s
    updateAuthorDisplayName.s
    updateAuthorActive.i
    updateAuthorTimeZone.s
    created.s
    updated.s
    visibilityType.s
    visibilityValue.s

    self = CkJsonObject::ckStringOf(jsonResponse,"self")
    id = CkJsonObject::ckStringOf(jsonResponse,"id")
    authorSelf = CkJsonObject::ckStringOf(jsonResponse,"author.self")
    authorName = CkJsonObject::ckStringOf(jsonResponse,"author.name")
    authorKey = CkJsonObject::ckStringOf(jsonResponse,"author.key")
    authorAccountId = CkJsonObject::ckStringOf(jsonResponse,"author.accountId")
    authorEmailAddress = CkJsonObject::ckStringOf(jsonResponse,"author.emailAddress")
    authorAvatarUrls48x48 = CkJsonObject::ckStringOf(jsonResponse,"author.avatarUrls.48x48")
    authorAvatarUrls24x24 = CkJsonObject::ckStringOf(jsonResponse,"author.avatarUrls.24x24")
    authorAvatarUrls16x16 = CkJsonObject::ckStringOf(jsonResponse,"author.avatarUrls.16x16")
    authorAvatarUrls32x32 = CkJsonObject::ckStringOf(jsonResponse,"author.avatarUrls.32x32")
    authorDisplayName = CkJsonObject::ckStringOf(jsonResponse,"author.displayName")
    authorActive = CkJsonObject::ckBoolOf(jsonResponse,"author.active")
    authorTimeZone = CkJsonObject::ckStringOf(jsonResponse,"author.timeZone")
    body = CkJsonObject::ckStringOf(jsonResponse,"body")
    updateAuthorSelf = CkJsonObject::ckStringOf(jsonResponse,"updateAuthor.self")
    updateAuthorName = CkJsonObject::ckStringOf(jsonResponse,"updateAuthor.name")
    updateAuthorKey = CkJsonObject::ckStringOf(jsonResponse,"updateAuthor.key")
    updateAuthorAccountId = CkJsonObject::ckStringOf(jsonResponse,"updateAuthor.accountId")
    updateAuthorEmailAddress = CkJsonObject::ckStringOf(jsonResponse,"updateAuthor.emailAddress")
    updateAuthorAvatarUrls48x48 = CkJsonObject::ckStringOf(jsonResponse,"updateAuthor.avatarUrls.48x48")
    updateAuthorAvatarUrls24x24 = CkJsonObject::ckStringOf(jsonResponse,"updateAuthor.avatarUrls.24x24")
    updateAuthorAvatarUrls16x16 = CkJsonObject::ckStringOf(jsonResponse,"updateAuthor.avatarUrls.16x16")
    updateAuthorAvatarUrls32x32 = CkJsonObject::ckStringOf(jsonResponse,"updateAuthor.avatarUrls.32x32")
    updateAuthorDisplayName = CkJsonObject::ckStringOf(jsonResponse,"updateAuthor.displayName")
    updateAuthorActive = CkJsonObject::ckBoolOf(jsonResponse,"updateAuthor.active")
    updateAuthorTimeZone = CkJsonObject::ckStringOf(jsonResponse,"updateAuthor.timeZone")
    created = CkJsonObject::ckStringOf(jsonResponse,"created")
    updated = CkJsonObject::ckStringOf(jsonResponse,"updated")
    visibilityType = CkJsonObject::ckStringOf(jsonResponse,"visibility.type")
    visibilityValue = CkJsonObject::ckStringOf(jsonResponse,"visibility.value")


    CkRest::ckDispose(rest)
    CkJsonObject::ckDispose(json)
    CkStringBuilder::ckDispose(sbRequestBody)
    CkStringBuilder::ckDispose(sbResponseBody)
    CkJsonObject::ckDispose(jsonResponse)


    ProcedureReturn
EndProcedure

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