Visual FoxPro 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'

Visual FoxPro Example

LOCAL loRest
LOCAL lnSuccess
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJsonResponse
LOCAL lcSelf
LOCAL lcId
LOCAL lcAuthorSelf
LOCAL lcAuthorName
LOCAL lcAuthorKey
LOCAL lcAuthorAccountId
LOCAL lcAuthorEmailAddress
LOCAL lcAuthorAvatarUrls48x48
LOCAL lcAuthorAvatarUrls24x24
LOCAL lcAuthorAvatarUrls16x16
LOCAL lcAuthorAvatarUrls32x32
LOCAL lcAuthorDisplayName
LOCAL lnAuthorActive
LOCAL lcAuthorTimeZone
LOCAL lcBody
LOCAL lcUpdateAuthorSelf
LOCAL lcUpdateAuthorName
LOCAL lcUpdateAuthorKey
LOCAL lcUpdateAuthorAccountId
LOCAL lcUpdateAuthorEmailAddress
LOCAL lcUpdateAuthorAvatarUrls48x48
LOCAL lcUpdateAuthorAvatarUrls24x24
LOCAL lcUpdateAuthorAvatarUrls16x16
LOCAL lcUpdateAuthorAvatarUrls32x32
LOCAL lcUpdateAuthorDisplayName
LOCAL lnUpdateAuthorActive
LOCAL lcUpdateAuthorTimeZone
LOCAL lcCreated
LOCAL lcUpdated
LOCAL lcVisibilityType
LOCAL lcVisibilityValue

loRest = CreateObject('Chilkat_9_5_0.Rest')

*  URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15/comment/10019
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("your-domain.atlassian.net",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
    ? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
    ? loRest.LastErrorText
    RELEASE loRest
    CANCEL
ENDIF

loRest.SetAuthBasic("jira@example.com","JIRA_API_TOKEN")

loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateString("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.")
loJson.UpdateString("visibility.type","role")
loJson.UpdateString("visibility.value","Administrators")

loRest.AddHeader("Content-Type","application/json")
loRest.AddHeader("Accept","application/json")

loSbRequestBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestSb("PUT","/rest/api/2/issue/SCRUM-15/comment/10019",loSbRequestBody,loSbResponseBody)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loJson
    RELEASE loSbRequestBody
    RELEASE loSbResponseBody
    CANCEL
ENDIF

lnRespStatusCode = loRest.ResponseStatusCode
IF (lnRespStatusCode >= 400) THEN
    ? "Response Status Code = " + STR(lnRespStatusCode)
    ? "Response Header:"
    ? loRest.ResponseHeader
    ? "Response Body:"
    ? loSbResponseBody.GetAsString()
    RELEASE loRest
    RELEASE loJson
    RELEASE loSbRequestBody
    RELEASE loSbResponseBody
    CANCEL
ENDIF

loJsonResponse = CreateObject('Chilkat_9_5_0.JsonObject')
loJsonResponse.LoadSb(loSbResponseBody)

lcSelf = loJsonResponse.StringOf("self")
lcId = loJsonResponse.StringOf("id")
lcAuthorSelf = loJsonResponse.StringOf("author.self")
lcAuthorName = loJsonResponse.StringOf("author.name")
lcAuthorKey = loJsonResponse.StringOf("author.key")
lcAuthorAccountId = loJsonResponse.StringOf("author.accountId")
lcAuthorEmailAddress = loJsonResponse.StringOf("author.emailAddress")
lcAuthorAvatarUrls48x48 = loJsonResponse.StringOf("author.avatarUrls.48x48")
lcAuthorAvatarUrls24x24 = loJsonResponse.StringOf("author.avatarUrls.24x24")
lcAuthorAvatarUrls16x16 = loJsonResponse.StringOf("author.avatarUrls.16x16")
lcAuthorAvatarUrls32x32 = loJsonResponse.StringOf("author.avatarUrls.32x32")
lcAuthorDisplayName = loJsonResponse.StringOf("author.displayName")
lnAuthorActive = loJsonResponse.BoolOf("author.active")
lcAuthorTimeZone = loJsonResponse.StringOf("author.timeZone")
lcBody = loJsonResponse.StringOf("body")
lcUpdateAuthorSelf = loJsonResponse.StringOf("updateAuthor.self")
lcUpdateAuthorName = loJsonResponse.StringOf("updateAuthor.name")
lcUpdateAuthorKey = loJsonResponse.StringOf("updateAuthor.key")
lcUpdateAuthorAccountId = loJsonResponse.StringOf("updateAuthor.accountId")
lcUpdateAuthorEmailAddress = loJsonResponse.StringOf("updateAuthor.emailAddress")
lcUpdateAuthorAvatarUrls48x48 = loJsonResponse.StringOf("updateAuthor.avatarUrls.48x48")
lcUpdateAuthorAvatarUrls24x24 = loJsonResponse.StringOf("updateAuthor.avatarUrls.24x24")
lcUpdateAuthorAvatarUrls16x16 = loJsonResponse.StringOf("updateAuthor.avatarUrls.16x16")
lcUpdateAuthorAvatarUrls32x32 = loJsonResponse.StringOf("updateAuthor.avatarUrls.32x32")
lcUpdateAuthorDisplayName = loJsonResponse.StringOf("updateAuthor.displayName")
lnUpdateAuthorActive = loJsonResponse.BoolOf("updateAuthor.active")
lcUpdateAuthorTimeZone = loJsonResponse.StringOf("updateAuthor.timeZone")
lcCreated = loJsonResponse.StringOf("created")
lcUpdated = loJsonResponse.StringOf("updated")
lcVisibilityType = loJsonResponse.StringOf("visibility.type")
lcVisibilityValue = loJsonResponse.StringOf("visibility.value")

RELEASE loRest
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJsonResponse

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