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'
load ./chilkat.dll
set rest [new_CkRest]
# URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15
set bTls 1
set port 443
set bAutoReconnect 1
set success [CkRest_Connect $rest "your-domain.atlassian.net" $port $bTls $bAutoReconnect]
if {[expr $success != 1]} then {
puts "ConnectFailReason: [CkRest_ConnectFailReason $rest]"
puts [CkRest_lastErrorText $rest]
delete_CkRest $rest
exit
}
CkRest_SetAuthBasic $rest "jira@example.com" "JIRA_API_TOKEN"
set json [new_CkJsonObject]
CkJsonObject_UpdateString $json "update.summary[0].set" "Bug in business logic"
CkJsonObject_UpdateString $json "update.labels[0].add" "triaged"
CkJsonObject_UpdateString $json "update.labels[1].remove" "blocker"
CkJsonObject_UpdateNumber $json "fields.customfield_10010" "1"
CkJsonObject_UpdateString $json "historyMetadata.type" "myplugin:type"
CkJsonObject_UpdateString $json "historyMetadata.description" "text description"
CkJsonObject_UpdateString $json "historyMetadata.descriptionKey" "plugin.changereason.i18.key"
CkJsonObject_UpdateString $json "historyMetadata.activityDescription" "text description"
CkJsonObject_UpdateString $json "historyMetadata.activityDescriptionKey" "plugin.activity.i18.key"
CkJsonObject_UpdateString $json "historyMetadata.actor.id" "tony"
CkJsonObject_UpdateString $json "historyMetadata.actor.displayName" "Tony"
CkJsonObject_UpdateString $json "historyMetadata.actor.type" "mysystem-user"
CkJsonObject_UpdateString $json "historyMetadata.actor.avatarUrl" "http://mysystem/avatar/tony.jpg"
CkJsonObject_UpdateString $json "historyMetadata.actor.url" "http://mysystem/users/tony"
CkJsonObject_UpdateString $json "historyMetadata.generator.id" "mysystem-1"
CkJsonObject_UpdateString $json "historyMetadata.generator.type" "mysystem-application"
CkJsonObject_UpdateString $json "historyMetadata.cause.id" "myevent"
CkJsonObject_UpdateString $json "historyMetadata.cause.type" "mysystem-event"
CkJsonObject_UpdateString $json "historyMetadata.extraData.keyvalue" "extra data"
CkJsonObject_UpdateString $json "historyMetadata.extraData.goes" "here"
CkJsonObject_UpdateString $json "properties[0].key" "key1"
CkJsonObject_UpdateString $json "properties[0].value" "can be set at issue create or update time"
CkJsonObject_UpdateString $json "properties[1].key" "key2"
CkJsonObject_UpdateString $json "properties[1].value" "and there can be multiple properties"
CkRest_AddHeader $rest "Content-Type" "application/json"
CkRest_AddHeader $rest "Accept" "application/json"
set sbRequestBody [new_CkStringBuilder]
CkJsonObject_EmitSb $json $sbRequestBody
set sbResponseBody [new_CkStringBuilder]
set success [CkRest_FullRequestSb $rest "PUT" "/rest/api/2/issue/SCRUM-15" $sbRequestBody $sbResponseBody]
if {[expr $success != 1]} then {
puts [CkRest_lastErrorText $rest]
delete_CkRest $rest
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody
delete_CkStringBuilder $sbResponseBody
exit
}
set respStatusCode [CkRest_ResponseStatusCode $rest]
if {[expr $respStatusCode >= 400]} then {
puts "Response Status Code = $respStatusCode"
puts "Response Header:"
puts [CkRest_responseHeader $rest]
puts "Response Body:"
puts [CkStringBuilder_getAsString $sbResponseBody]
delete_CkRest $rest
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody
delete_CkStringBuilder $sbResponseBody
exit
}
delete_CkRest $rest
delete_CkJsonObject $json
delete_CkStringBuilder $sbRequestBody
delete_CkStringBuilder $sbResponseBody