Edits the issue from a JSON representation. This example updates the issue having key = "SCRUM-15". A successful update is indicated by a response status code equal to 204 with an empty response body.
curl -X PUT --user jira@example.com:JIRA_API_TOKEN \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '
{
"update": {
"summary": [
{
"set": "Bug in business logic"
}
],
"labels": [
{
"add": "triaged"
},
{
"remove": "blocker"
}
]
},
"fields": {
"customfield_10010": 1
},
"historyMetadata": {
"type": "myplugin:type",
"description": "text description",
"descriptionKey": "plugin.changereason.i18.key",
"activityDescription": "text description",
"activityDescriptionKey": "plugin.activity.i18.key",
"actor": {
"id": "tony",
"displayName": "Tony",
"type": "mysystem-user",
"avatarUrl": "http://mysystem/avatar/tony.jpg",
"url": "http://mysystem/users/tony"
},
"generator": {
"id": "mysystem-1",
"type": "mysystem-application"
},
"cause": {
"id": "myevent",
"type": "mysystem-event"
},
"extraData": {
"keyvalue": "extra data",
"goes": "here"
}
},
"properties": [
{
"key": "key1",
"value": "can be set at issue create or update time"
},
{
"key": "key2",
"value": "and there can be multiple properties"
}
]
}' \
--url 'https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15'
#include <CkRestW.h>
#include <CkJsonObjectW.h>
#include <CkStringBuilderW.h>
void ChilkatSample(void)
{
CkRestW rest;
bool success;
// URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15
bool bTls = true;
int port = 443;
bool bAutoReconnect = true;
success = rest.Connect(L"your-domain.atlassian.net",port,bTls,bAutoReconnect);
if (success != true) {
wprintf(L"ConnectFailReason: %d\n",rest.get_ConnectFailReason());
wprintf(L"%s\n",rest.lastErrorText());
return;
}
rest.SetAuthBasic(L"jira@example.com",L"JIRA_API_TOKEN");
CkJsonObjectW json;
json.UpdateString(L"update.summary[0].set",L"Bug in business logic");
json.UpdateString(L"update.labels[0].add",L"triaged");
json.UpdateString(L"update.labels[1].remove",L"blocker");
json.UpdateNumber(L"fields.customfield_10010",L"1");
json.UpdateString(L"historyMetadata.type",L"myplugin:type");
json.UpdateString(L"historyMetadata.description",L"text description");
json.UpdateString(L"historyMetadata.descriptionKey",L"plugin.changereason.i18.key");
json.UpdateString(L"historyMetadata.activityDescription",L"text description");
json.UpdateString(L"historyMetadata.activityDescriptionKey",L"plugin.activity.i18.key");
json.UpdateString(L"historyMetadata.actor.id",L"tony");
json.UpdateString(L"historyMetadata.actor.displayName",L"Tony");
json.UpdateString(L"historyMetadata.actor.type",L"mysystem-user");
json.UpdateString(L"historyMetadata.actor.avatarUrl",L"http://mysystem/avatar/tony.jpg");
json.UpdateString(L"historyMetadata.actor.url",L"http://mysystem/users/tony");
json.UpdateString(L"historyMetadata.generator.id",L"mysystem-1");
json.UpdateString(L"historyMetadata.generator.type",L"mysystem-application");
json.UpdateString(L"historyMetadata.cause.id",L"myevent");
json.UpdateString(L"historyMetadata.cause.type",L"mysystem-event");
json.UpdateString(L"historyMetadata.extraData.keyvalue",L"extra data");
json.UpdateString(L"historyMetadata.extraData.goes",L"here");
json.UpdateString(L"properties[0].key",L"key1");
json.UpdateString(L"properties[0].value",L"can be set at issue create or update time");
json.UpdateString(L"properties[1].key",L"key2");
json.UpdateString(L"properties[1].value",L"and there can be multiple properties");
rest.AddHeader(L"Content-Type",L"application/json");
rest.AddHeader(L"Accept",L"application/json");
CkStringBuilderW sbRequestBody;
json.EmitSb(sbRequestBody);
CkStringBuilderW sbResponseBody;
success = rest.FullRequestSb(L"PUT",L"/rest/api/2/issue/SCRUM-15",sbRequestBody,sbResponseBody);
if (success != true) {
wprintf(L"%s\n",rest.lastErrorText());
return;
}
int respStatusCode = rest.get_ResponseStatusCode();
if (respStatusCode >= 400) {
wprintf(L"Response Status Code = %d\n",respStatusCode);
wprintf(L"Response Header:\n");
wprintf(L"%s\n",rest.responseHeader());
wprintf(L"Response Body:\n");
wprintf(L"%s\n",sbResponseBody.getAsString());
return;
}
}