Objective-C 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'

Objective-C Example

#import <CkoRest.h>
#import <CkoJsonObject.h>
#import <CkoStringBuilder.h>
#import <NSString.h>

CkoRest *rest = [[CkoRest alloc] init];
BOOL success;

//  URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15/comment/10019
BOOL bTls = YES;
int port = 443;
BOOL bAutoReconnect = YES;
success = [rest Connect: @"your-domain.atlassian.net" port: [NSNumber numberWithInt: port] tls: bTls autoReconnect: bAutoReconnect];
if (success != YES) {
    NSLog(@"%@%d",@"ConnectFailReason: ",[rest.ConnectFailReason intValue]);
    NSLog(@"%@",rest.LastErrorText);
    return;
}

[rest SetAuthBasic: @"jira@example.com" password: @"JIRA_API_TOKEN"];

CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"body" value: @"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."];
[json UpdateString: @"visibility.type" value: @"role"];
[json UpdateString: @"visibility.value" value: @"Administrators"];

[rest AddHeader: @"Content-Type" value: @"application/json"];
[rest AddHeader: @"Accept" value: @"application/json"];

CkoStringBuilder *sbRequestBody = [[CkoStringBuilder alloc] init];
[json EmitSb: sbRequestBody];
CkoStringBuilder *sbResponseBody = [[CkoStringBuilder alloc] init];
success = [rest FullRequestSb: @"PUT" uriPath: @"/rest/api/2/issue/SCRUM-15/comment/10019" requestBody: sbRequestBody responseBody: sbResponseBody];
if (success != YES) {
    NSLog(@"%@",rest.LastErrorText);
    return;
}

int respStatusCode = [rest.ResponseStatusCode intValue];
if (respStatusCode >= 400) {
    NSLog(@"%@%d",@"Response Status Code = ",respStatusCode);
    NSLog(@"%@",@"Response Header:");
    NSLog(@"%@",rest.ResponseHeader);
    NSLog(@"%@",@"Response Body:");
    NSLog(@"%@",[sbResponseBody GetAsString]);
    return;
}

CkoJsonObject *jsonResponse = [[CkoJsonObject alloc] init];
[jsonResponse LoadSb: sbResponseBody];

NSString *self = 0;
NSString *id = 0;
NSString *authorSelf = 0;
NSString *authorName = 0;
NSString *authorKey = 0;
NSString *authorAccountId = 0;
NSString *authorEmailAddress = 0;
NSString *authorAvatarUrls48x48 = 0;
NSString *authorAvatarUrls24x24 = 0;
NSString *authorAvatarUrls16x16 = 0;
NSString *authorAvatarUrls32x32 = 0;
NSString *authorDisplayName = 0;
BOOL authorActive;
NSString *authorTimeZone = 0;
NSString *body = 0;
NSString *updateAuthorSelf = 0;
NSString *updateAuthorName = 0;
NSString *updateAuthorKey = 0;
NSString *updateAuthorAccountId = 0;
NSString *updateAuthorEmailAddress = 0;
NSString *updateAuthorAvatarUrls48x48 = 0;
NSString *updateAuthorAvatarUrls24x24 = 0;
NSString *updateAuthorAvatarUrls16x16 = 0;
NSString *updateAuthorAvatarUrls32x32 = 0;
NSString *updateAuthorDisplayName = 0;
BOOL updateAuthorActive;
NSString *updateAuthorTimeZone = 0;
NSString *created = 0;
NSString *updated = 0;
NSString *visibilityType = 0;
NSString *visibilityValue = 0;

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

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