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'
func chilkatTest() {
let rest = CkoRest()
var success: Bool
// URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15
var bTls: Bool = true
var port: Int = 443
var bAutoReconnect: Bool = true
success = rest.Connect("your-domain.atlassian.net", port: port, tls: bTls, autoReconnect: bAutoReconnect)
if success != true {
print("ConnectFailReason: \(rest.ConnectFailReason.intValue)")
print("\(rest.LastErrorText)")
return
}
rest.SetAuthBasic("jira@example.com", password: "JIRA_API_TOKEN")
let json = CkoJsonObject()
json.UpdateString("update.summary[0].set", value: "Bug in business logic")
json.UpdateString("update.labels[0].add", value: "triaged")
json.UpdateString("update.labels[1].remove", value: "blocker")
json.UpdateNumber("fields.customfield_10010", numericStr: "1")
json.UpdateString("historyMetadata.type", value: "myplugin:type")
json.UpdateString("historyMetadata.description", value: "text description")
json.UpdateString("historyMetadata.descriptionKey", value: "plugin.changereason.i18.key")
json.UpdateString("historyMetadata.activityDescription", value: "text description")
json.UpdateString("historyMetadata.activityDescriptionKey", value: "plugin.activity.i18.key")
json.UpdateString("historyMetadata.actor.id", value: "tony")
json.UpdateString("historyMetadata.actor.displayName", value: "Tony")
json.UpdateString("historyMetadata.actor.type", value: "mysystem-user")
json.UpdateString("historyMetadata.actor.avatarUrl", value: "http://mysystem/avatar/tony.jpg")
json.UpdateString("historyMetadata.actor.url", value: "http://mysystem/users/tony")
json.UpdateString("historyMetadata.generator.id", value: "mysystem-1")
json.UpdateString("historyMetadata.generator.type", value: "mysystem-application")
json.UpdateString("historyMetadata.cause.id", value: "myevent")
json.UpdateString("historyMetadata.cause.type", value: "mysystem-event")
json.UpdateString("historyMetadata.extraData.keyvalue", value: "extra data")
json.UpdateString("historyMetadata.extraData.goes", value: "here")
json.UpdateString("properties[0].key", value: "key1")
json.UpdateString("properties[0].value", value: "can be set at issue create or update time")
json.UpdateString("properties[1].key", value: "key2")
json.UpdateString("properties[1].value", value: "and there can be multiple properties")
rest.AddHeader("Content-Type", value: "application/json")
rest.AddHeader("Accept", value: "application/json")
let sbRequestBody = CkoStringBuilder()
json.EmitSb(sbRequestBody)
let sbResponseBody = CkoStringBuilder()
success = rest.FullRequestSb("PUT", uriPath: "/rest/api/2/issue/SCRUM-15", requestBody: sbRequestBody, responseBody: sbResponseBody)
if success != true {
print("\(rest.LastErrorText)")
return
}
var respStatusCode: Int = rest.ResponseStatusCode.intValue
if respStatusCode >= 400 {
print("Response Status Code = \(respStatusCode)")
print("Response Header:")
print("\(rest.ResponseHeader)")
print("Response Body:")
print("\(sbResponseBody.GetAsString())")
return
}
}