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'
IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkRest.pb"
Procedure ChilkatExample()
rest.i = CkRest::ckCreate()
If rest.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
; URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15
bTls.i = 1
port.i = 443
bAutoReconnect.i = 1
success = CkRest::ckConnect(rest,"your-domain.atlassian.net",port,bTls,bAutoReconnect)
If success <> 1
Debug "ConnectFailReason: " + Str(CkRest::ckConnectFailReason(rest))
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
ProcedureReturn
EndIf
CkRest::ckSetAuthBasic(rest,"jira@example.com","JIRA_API_TOKEN")
json.i = CkJsonObject::ckCreate()
If json.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckUpdateString(json,"update.summary[0].set","Bug in business logic")
CkJsonObject::ckUpdateString(json,"update.labels[0].add","triaged")
CkJsonObject::ckUpdateString(json,"update.labels[1].remove","blocker")
CkJsonObject::ckUpdateNumber(json,"fields.customfield_10010","1")
CkJsonObject::ckUpdateString(json,"historyMetadata.type","myplugin:type")
CkJsonObject::ckUpdateString(json,"historyMetadata.description","text description")
CkJsonObject::ckUpdateString(json,"historyMetadata.descriptionKey","plugin.changereason.i18.key")
CkJsonObject::ckUpdateString(json,"historyMetadata.activityDescription","text description")
CkJsonObject::ckUpdateString(json,"historyMetadata.activityDescriptionKey","plugin.activity.i18.key")
CkJsonObject::ckUpdateString(json,"historyMetadata.actor.id","tony")
CkJsonObject::ckUpdateString(json,"historyMetadata.actor.displayName","Tony")
CkJsonObject::ckUpdateString(json,"historyMetadata.actor.type","mysystem-user")
CkJsonObject::ckUpdateString(json,"historyMetadata.actor.avatarUrl","http://mysystem/avatar/tony.jpg")
CkJsonObject::ckUpdateString(json,"historyMetadata.actor.url","http://mysystem/users/tony")
CkJsonObject::ckUpdateString(json,"historyMetadata.generator.id","mysystem-1")
CkJsonObject::ckUpdateString(json,"historyMetadata.generator.type","mysystem-application")
CkJsonObject::ckUpdateString(json,"historyMetadata.cause.id","myevent")
CkJsonObject::ckUpdateString(json,"historyMetadata.cause.type","mysystem-event")
CkJsonObject::ckUpdateString(json,"historyMetadata.extraData.keyvalue","extra data")
CkJsonObject::ckUpdateString(json,"historyMetadata.extraData.goes","here")
CkJsonObject::ckUpdateString(json,"properties[0].key","key1")
CkJsonObject::ckUpdateString(json,"properties[0].value","can be set at issue create or update time")
CkJsonObject::ckUpdateString(json,"properties[1].key","key2")
CkJsonObject::ckUpdateString(json,"properties[1].value","and there can be multiple properties")
CkRest::ckAddHeader(rest,"Content-Type","application/json")
CkRest::ckAddHeader(rest,"Accept","application/json")
sbRequestBody.i = CkStringBuilder::ckCreate()
If sbRequestBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkJsonObject::ckEmitSb(json,sbRequestBody)
sbResponseBody.i = CkStringBuilder::ckCreate()
If sbResponseBody.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkRest::ckFullRequestSb(rest,"PUT","/rest/api/2/issue/SCRUM-15",sbRequestBody,sbResponseBody)
If success <> 1
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbRequestBody)
CkStringBuilder::ckDispose(sbResponseBody)
ProcedureReturn
EndIf
respStatusCode.i = CkRest::ckResponseStatusCode(rest)
If respStatusCode >= 400
Debug "Response Status Code = " + Str(respStatusCode)
Debug "Response Header:"
Debug CkRest::ckResponseHeader(rest)
Debug "Response Body:"
Debug CkStringBuilder::ckGetAsString(sbResponseBody)
CkRest::ckDispose(rest)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbRequestBody)
CkStringBuilder::ckDispose(sbResponseBody)
ProcedureReturn
EndIf
CkRest::ckDispose(rest)
CkJsonObject::ckDispose(json)
CkStringBuilder::ckDispose(sbRequestBody)
CkStringBuilder::ckDispose(sbResponseBody)
ProcedureReturn
EndProcedure