Adds a new comment to an issue. This example adds a comment for the issue with key = "SCRUM-15".
curl --user jira@example.com:JIRA_API_TOKEN \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '
{
"body": "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'
var
rest: HCkRest;
success: Boolean;
bTls: Boolean;
port: Integer;
bAutoReconnect: Boolean;
json: HCkJsonObject;
sbRequestBody: HCkStringBuilder;
sbResponseBody: HCkStringBuilder;
respStatusCode: Integer;
jsonResponse: HCkJsonObject;
self: PWideChar;
id: PWideChar;
authorSelf: PWideChar;
authorName: PWideChar;
authorKey: PWideChar;
authorAccountId: PWideChar;
authorEmailAddress: PWideChar;
authorAvatarUrls48x48: PWideChar;
authorAvatarUrls24x24: PWideChar;
authorAvatarUrls16x16: PWideChar;
authorAvatarUrls32x32: PWideChar;
authorDisplayName: PWideChar;
authorActive: Boolean;
authorTimeZone: PWideChar;
body: PWideChar;
updateAuthorSelf: PWideChar;
updateAuthorName: PWideChar;
updateAuthorKey: PWideChar;
updateAuthorAccountId: PWideChar;
updateAuthorEmailAddress: PWideChar;
updateAuthorAvatarUrls48x48: PWideChar;
updateAuthorAvatarUrls24x24: PWideChar;
updateAuthorAvatarUrls16x16: PWideChar;
updateAuthorAvatarUrls32x32: PWideChar;
updateAuthorDisplayName: PWideChar;
updateAuthorActive: Boolean;
updateAuthorTimeZone: PWideChar;
created: PWideChar;
updated: PWideChar;
visibilityType: PWideChar;
visibilityValue: PWideChar;
begin
rest := CkRest_Create();
// URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15/comment
bTls := True;
port := 443;
bAutoReconnect := True;
success := CkRest_Connect(rest,'your-domain.atlassian.net',port,bTls,bAutoReconnect);
if (success <> True) then
begin
Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(CkRest_getConnectFailReason(rest)));
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
CkRest_SetAuthBasic(rest,'jira@example.com','JIRA_API_TOKEN');
json := CkJsonObject_Create();
CkJsonObject_UpdateString(json,'body','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');
sbRequestBody := CkStringBuilder_Create();
CkJsonObject_EmitSb(json,sbRequestBody);
sbResponseBody := CkStringBuilder_Create();
success := CkRest_FullRequestSb(rest,'POST','/rest/api/2/issue/SCRUM-15/comment',sbRequestBody,sbResponseBody);
if (success <> True) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
respStatusCode := CkRest_getResponseStatusCode(rest);
if (respStatusCode >= 400) then
begin
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
Memo1.Lines.Add('Response Header:');
Memo1.Lines.Add(CkRest__responseHeader(rest));
Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(CkStringBuilder__getAsString(sbResponseBody));
Exit;
end;
jsonResponse := CkJsonObject_Create();
CkJsonObject_LoadSb(jsonResponse,sbResponseBody);
self := CkJsonObject__stringOf(jsonResponse,'self');
id := CkJsonObject__stringOf(jsonResponse,'id');
authorSelf := CkJsonObject__stringOf(jsonResponse,'author.self');
authorName := CkJsonObject__stringOf(jsonResponse,'author.name');
authorKey := CkJsonObject__stringOf(jsonResponse,'author.key');
authorAccountId := CkJsonObject__stringOf(jsonResponse,'author.accountId');
authorEmailAddress := CkJsonObject__stringOf(jsonResponse,'author.emailAddress');
authorAvatarUrls48x48 := CkJsonObject__stringOf(jsonResponse,'author.avatarUrls.48x48');
authorAvatarUrls24x24 := CkJsonObject__stringOf(jsonResponse,'author.avatarUrls.24x24');
authorAvatarUrls16x16 := CkJsonObject__stringOf(jsonResponse,'author.avatarUrls.16x16');
authorAvatarUrls32x32 := CkJsonObject__stringOf(jsonResponse,'author.avatarUrls.32x32');
authorDisplayName := CkJsonObject__stringOf(jsonResponse,'author.displayName');
authorActive := CkJsonObject_BoolOf(jsonResponse,'author.active');
authorTimeZone := CkJsonObject__stringOf(jsonResponse,'author.timeZone');
body := CkJsonObject__stringOf(jsonResponse,'body');
updateAuthorSelf := CkJsonObject__stringOf(jsonResponse,'updateAuthor.self');
updateAuthorName := CkJsonObject__stringOf(jsonResponse,'updateAuthor.name');
updateAuthorKey := CkJsonObject__stringOf(jsonResponse,'updateAuthor.key');
updateAuthorAccountId := CkJsonObject__stringOf(jsonResponse,'updateAuthor.accountId');
updateAuthorEmailAddress := CkJsonObject__stringOf(jsonResponse,'updateAuthor.emailAddress');
updateAuthorAvatarUrls48x48 := CkJsonObject__stringOf(jsonResponse,'updateAuthor.avatarUrls.48x48');
updateAuthorAvatarUrls24x24 := CkJsonObject__stringOf(jsonResponse,'updateAuthor.avatarUrls.24x24');
updateAuthorAvatarUrls16x16 := CkJsonObject__stringOf(jsonResponse,'updateAuthor.avatarUrls.16x16');
updateAuthorAvatarUrls32x32 := CkJsonObject__stringOf(jsonResponse,'updateAuthor.avatarUrls.32x32');
updateAuthorDisplayName := CkJsonObject__stringOf(jsonResponse,'updateAuthor.displayName');
updateAuthorActive := CkJsonObject_BoolOf(jsonResponse,'updateAuthor.active');
updateAuthorTimeZone := CkJsonObject__stringOf(jsonResponse,'updateAuthor.timeZone');
created := CkJsonObject__stringOf(jsonResponse,'created');
updated := CkJsonObject__stringOf(jsonResponse,'updated');
visibilityType := CkJsonObject__stringOf(jsonResponse,'visibility.type');
visibilityValue := CkJsonObject__stringOf(jsonResponse,'visibility.value');
CkRest_Dispose(rest);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbRequestBody);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jsonResponse);
{
"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": "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:14:41.741-0500",
"visibility": {
"type": "role",
"value": "Administrators"
}
}