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'
#include <C_CkRestW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkStringBuilderW.h>
void ChilkatSample(void)
{
HCkRestW rest;
BOOL success;
BOOL bTls;
int port;
BOOL bAutoReconnect;
HCkJsonObjectW json;
HCkStringBuilderW sbRequestBody;
HCkStringBuilderW sbResponseBody;
int respStatusCode;
HCkJsonObjectW jsonResponse;
const wchar_t *self;
const wchar_t *id;
const wchar_t *authorSelf;
const wchar_t *authorName;
const wchar_t *authorKey;
const wchar_t *authorAccountId;
const wchar_t *authorEmailAddress;
const wchar_t *authorAvatarUrls48x48;
const wchar_t *authorAvatarUrls24x24;
const wchar_t *authorAvatarUrls16x16;
const wchar_t *authorAvatarUrls32x32;
const wchar_t *authorDisplayName;
BOOL authorActive;
const wchar_t *authorTimeZone;
const wchar_t *body;
const wchar_t *updateAuthorSelf;
const wchar_t *updateAuthorName;
const wchar_t *updateAuthorKey;
const wchar_t *updateAuthorAccountId;
const wchar_t *updateAuthorEmailAddress;
const wchar_t *updateAuthorAvatarUrls48x48;
const wchar_t *updateAuthorAvatarUrls24x24;
const wchar_t *updateAuthorAvatarUrls16x16;
const wchar_t *updateAuthorAvatarUrls32x32;
const wchar_t *updateAuthorDisplayName;
BOOL updateAuthorActive;
const wchar_t *updateAuthorTimeZone;
const wchar_t *created;
const wchar_t *updated;
const wchar_t *visibilityType;
const wchar_t *visibilityValue;
rest = CkRestW_Create();
// URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15/comment
bTls = TRUE;
port = 443;
bAutoReconnect = TRUE;
success = CkRestW_Connect(rest,L"your-domain.atlassian.net",port,bTls,bAutoReconnect);
if (success != TRUE) {
wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
return;
}
CkRestW_SetAuthBasic(rest,L"jira@example.com",L"JIRA_API_TOKEN");
json = CkJsonObjectW_Create();
CkJsonObjectW_UpdateString(json,L"body",L"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.");
CkJsonObjectW_UpdateString(json,L"visibility.type",L"role");
CkJsonObjectW_UpdateString(json,L"visibility.value",L"Administrators");
CkRestW_AddHeader(rest,L"Content-Type",L"application/json");
CkRestW_AddHeader(rest,L"Accept",L"application/json");
sbRequestBody = CkStringBuilderW_Create();
CkJsonObjectW_EmitSb(json,sbRequestBody);
sbResponseBody = CkStringBuilderW_Create();
success = CkRestW_FullRequestSb(rest,L"POST",L"/rest/api/2/issue/SCRUM-15/comment",sbRequestBody,sbResponseBody);
if (success != TRUE) {
wprintf(L"%s\n",CkRestW_lastErrorText(rest));
CkRestW_Dispose(rest);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
respStatusCode = CkRestW_getResponseStatusCode(rest);
if (respStatusCode >= 400) {
wprintf(L"Response Status Code = %d\n",respStatusCode);
wprintf(L"Response Header:\n");
wprintf(L"%s\n",CkRestW_responseHeader(rest));
wprintf(L"Response Body:\n");
wprintf(L"%s\n",CkStringBuilderW_getAsString(sbResponseBody));
CkRestW_Dispose(rest);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
return;
}
jsonResponse = CkJsonObjectW_Create();
CkJsonObjectW_LoadSb(jsonResponse,sbResponseBody);
self = CkJsonObjectW_stringOf(jsonResponse,L"self");
id = CkJsonObjectW_stringOf(jsonResponse,L"id");
authorSelf = CkJsonObjectW_stringOf(jsonResponse,L"author.self");
authorName = CkJsonObjectW_stringOf(jsonResponse,L"author.name");
authorKey = CkJsonObjectW_stringOf(jsonResponse,L"author.key");
authorAccountId = CkJsonObjectW_stringOf(jsonResponse,L"author.accountId");
authorEmailAddress = CkJsonObjectW_stringOf(jsonResponse,L"author.emailAddress");
authorAvatarUrls48x48 = CkJsonObjectW_stringOf(jsonResponse,L"author.avatarUrls.48x48");
authorAvatarUrls24x24 = CkJsonObjectW_stringOf(jsonResponse,L"author.avatarUrls.24x24");
authorAvatarUrls16x16 = CkJsonObjectW_stringOf(jsonResponse,L"author.avatarUrls.16x16");
authorAvatarUrls32x32 = CkJsonObjectW_stringOf(jsonResponse,L"author.avatarUrls.32x32");
authorDisplayName = CkJsonObjectW_stringOf(jsonResponse,L"author.displayName");
authorActive = CkJsonObjectW_BoolOf(jsonResponse,L"author.active");
authorTimeZone = CkJsonObjectW_stringOf(jsonResponse,L"author.timeZone");
body = CkJsonObjectW_stringOf(jsonResponse,L"body");
updateAuthorSelf = CkJsonObjectW_stringOf(jsonResponse,L"updateAuthor.self");
updateAuthorName = CkJsonObjectW_stringOf(jsonResponse,L"updateAuthor.name");
updateAuthorKey = CkJsonObjectW_stringOf(jsonResponse,L"updateAuthor.key");
updateAuthorAccountId = CkJsonObjectW_stringOf(jsonResponse,L"updateAuthor.accountId");
updateAuthorEmailAddress = CkJsonObjectW_stringOf(jsonResponse,L"updateAuthor.emailAddress");
updateAuthorAvatarUrls48x48 = CkJsonObjectW_stringOf(jsonResponse,L"updateAuthor.avatarUrls.48x48");
updateAuthorAvatarUrls24x24 = CkJsonObjectW_stringOf(jsonResponse,L"updateAuthor.avatarUrls.24x24");
updateAuthorAvatarUrls16x16 = CkJsonObjectW_stringOf(jsonResponse,L"updateAuthor.avatarUrls.16x16");
updateAuthorAvatarUrls32x32 = CkJsonObjectW_stringOf(jsonResponse,L"updateAuthor.avatarUrls.32x32");
updateAuthorDisplayName = CkJsonObjectW_stringOf(jsonResponse,L"updateAuthor.displayName");
updateAuthorActive = CkJsonObjectW_BoolOf(jsonResponse,L"updateAuthor.active");
updateAuthorTimeZone = CkJsonObjectW_stringOf(jsonResponse,L"updateAuthor.timeZone");
created = CkJsonObjectW_stringOf(jsonResponse,L"created");
updated = CkJsonObjectW_stringOf(jsonResponse,L"updated");
visibilityType = CkJsonObjectW_stringOf(jsonResponse,L"visibility.type");
visibilityValue = CkJsonObjectW_stringOf(jsonResponse,L"visibility.value");
CkRestW_Dispose(rest);
CkJsonObjectW_Dispose(json);
CkStringBuilderW_Dispose(sbRequestBody);
CkStringBuilderW_Dispose(sbResponseBody);
CkJsonObjectW_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"
}
}