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'
Use ChilkatAx-9.5.0-win32.pkg
Procedure Test
Handle hoRest
Boolean iSuccess
Boolean iBTls
Integer iPort
Boolean iBAutoReconnect
Handle hoJson
Variant vSbRequestBody
Handle hoSbRequestBody
Variant vSbResponseBody
Handle hoSbResponseBody
Integer iRespStatusCode
String sTemp1
Integer iTemp1
Get Create (RefClass(cComChilkatRest)) To hoRest
If (Not(IsComObjectCreated(hoRest))) Begin
Send CreateComObject of hoRest
End
// URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15
Move True To iBTls
Move 443 To iPort
Move True To iBAutoReconnect
Get ComConnect Of hoRest "your-domain.atlassian.net" iPort iBTls iBAutoReconnect To iSuccess
If (iSuccess <> True) Begin
Get ComConnectFailReason Of hoRest To iTemp1
Showln "ConnectFailReason: " iTemp1
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComSetAuthBasic Of hoRest "jira@example.com" "JIRA_API_TOKEN" To iSuccess
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateString Of hoJson "update.summary[0].set" "Bug in business logic" To iSuccess
Get ComUpdateString Of hoJson "update.labels[0].add" "triaged" To iSuccess
Get ComUpdateString Of hoJson "update.labels[1].remove" "blocker" To iSuccess
Get ComUpdateNumber Of hoJson "fields.customfield_10010" "1" To iSuccess
Get ComUpdateString Of hoJson "historyMetadata.type" "myplugin:type" To iSuccess
Get ComUpdateString Of hoJson "historyMetadata.description" "text description" To iSuccess
Get ComUpdateString Of hoJson "historyMetadata.descriptionKey" "plugin.changereason.i18.key" To iSuccess
Get ComUpdateString Of hoJson "historyMetadata.activityDescription" "text description" To iSuccess
Get ComUpdateString Of hoJson "historyMetadata.activityDescriptionKey" "plugin.activity.i18.key" To iSuccess
Get ComUpdateString Of hoJson "historyMetadata.actor.id" "tony" To iSuccess
Get ComUpdateString Of hoJson "historyMetadata.actor.displayName" "Tony" To iSuccess
Get ComUpdateString Of hoJson "historyMetadata.actor.type" "mysystem-user" To iSuccess
Get ComUpdateString Of hoJson "historyMetadata.actor.avatarUrl" "http://mysystem/avatar/tony.jpg" To iSuccess
Get ComUpdateString Of hoJson "historyMetadata.actor.url" "http://mysystem/users/tony" To iSuccess
Get ComUpdateString Of hoJson "historyMetadata.generator.id" "mysystem-1" To iSuccess
Get ComUpdateString Of hoJson "historyMetadata.generator.type" "mysystem-application" To iSuccess
Get ComUpdateString Of hoJson "historyMetadata.cause.id" "myevent" To iSuccess
Get ComUpdateString Of hoJson "historyMetadata.cause.type" "mysystem-event" To iSuccess
Get ComUpdateString Of hoJson "historyMetadata.extraData.keyvalue" "extra data" To iSuccess
Get ComUpdateString Of hoJson "historyMetadata.extraData.goes" "here" To iSuccess
Get ComUpdateString Of hoJson "properties[0].key" "key1" To iSuccess
Get ComUpdateString Of hoJson "properties[0].value" "can be set at issue create or update time" To iSuccess
Get ComUpdateString Of hoJson "properties[1].key" "key2" To iSuccess
Get ComUpdateString Of hoJson "properties[1].value" "and there can be multiple properties" To iSuccess
Get ComAddHeader Of hoRest "Content-Type" "application/json" To iSuccess
Get ComAddHeader Of hoRest "Accept" "application/json" To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbRequestBody
If (Not(IsComObjectCreated(hoSbRequestBody))) Begin
Send CreateComObject of hoSbRequestBody
End
Get pvComObject of hoSbRequestBody to vSbRequestBody
Get ComEmitSb Of hoJson vSbRequestBody To iSuccess
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbRequestBody to vSbRequestBody
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComFullRequestSb Of hoRest "PUT" "/rest/api/2/issue/SCRUM-15" vSbRequestBody vSbResponseBody To iSuccess
If (iSuccess <> True) Begin
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComResponseStatusCode Of hoRest To iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Status Code = " iRespStatusCode
Showln "Response Header:"
Get ComResponseHeader Of hoRest To sTemp1
Showln sTemp1
Showln "Response Body:"
Get ComGetAsString Of hoSbResponseBody To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure