Android™ Jira - Issues: Edit an Issue

Back to Index

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.

Documentation: https://developers.atlassian.com/cloud/jira/platform/rest/#api-api-2-issue-issueIdOrKey-put

CURL Command

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'

Android™ Example

// Important: Don't forget to include the call to System.loadLibrary
// as shown at the bottom of this code sample.
package com.test;

import android.app.Activity;
import com.chilkatsoft.*;

import android.widget.TextView;
import android.os.Bundle;

public class SimpleActivity extends Activity {

  private static final String TAG = "Chilkat";

  // Called when the activity is first created.
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    CkRest rest = new CkRest();
    boolean success;

    //  URL: https://your-domain.atlassian.net/rest/api/2/issue/SCRUM-15
    boolean bTls = true;
    int port = 443;
    boolean bAutoReconnect = true;
    success = rest.Connect("your-domain.atlassian.net",port,bTls,bAutoReconnect);
    if (success != true) {
        Log.i(TAG, "ConnectFailReason: " + String.valueOf(rest.get_ConnectFailReason()));
        Log.i(TAG, rest.lastErrorText());
        return;
        }

    rest.SetAuthBasic("jira@example.com","JIRA_API_TOKEN");

    CkJsonObject json = new CkJsonObject();
    json.UpdateString("update.summary[0].set","Bug in business logic");
    json.UpdateString("update.labels[0].add","triaged");
    json.UpdateString("update.labels[1].remove","blocker");
    json.UpdateNumber("fields.customfield_10010","1");
    json.UpdateString("historyMetadata.type","myplugin:type");
    json.UpdateString("historyMetadata.description","text description");
    json.UpdateString("historyMetadata.descriptionKey","plugin.changereason.i18.key");
    json.UpdateString("historyMetadata.activityDescription","text description");
    json.UpdateString("historyMetadata.activityDescriptionKey","plugin.activity.i18.key");
    json.UpdateString("historyMetadata.actor.id","tony");
    json.UpdateString("historyMetadata.actor.displayName","Tony");
    json.UpdateString("historyMetadata.actor.type","mysystem-user");
    json.UpdateString("historyMetadata.actor.avatarUrl","http://mysystem/avatar/tony.jpg");
    json.UpdateString("historyMetadata.actor.url","http://mysystem/users/tony");
    json.UpdateString("historyMetadata.generator.id","mysystem-1");
    json.UpdateString("historyMetadata.generator.type","mysystem-application");
    json.UpdateString("historyMetadata.cause.id","myevent");
    json.UpdateString("historyMetadata.cause.type","mysystem-event");
    json.UpdateString("historyMetadata.extraData.keyvalue","extra data");
    json.UpdateString("historyMetadata.extraData.goes","here");
    json.UpdateString("properties[0].key","key1");
    json.UpdateString("properties[0].value","can be set at issue create or update time");
    json.UpdateString("properties[1].key","key2");
    json.UpdateString("properties[1].value","and there can be multiple properties");

    rest.AddHeader("Content-Type","application/json");
    rest.AddHeader("Accept","application/json");

    CkStringBuilder sbRequestBody = new CkStringBuilder();
    json.EmitSb(sbRequestBody);
    CkStringBuilder sbResponseBody = new CkStringBuilder();
    success = rest.FullRequestSb("PUT","/rest/api/2/issue/SCRUM-15",sbRequestBody,sbResponseBody);
    if (success != true) {
        Log.i(TAG, rest.lastErrorText());
        return;
        }

    int respStatusCode = rest.get_ResponseStatusCode();
    if (respStatusCode >= 400) {
        Log.i(TAG, "Response Status Code = " + String.valueOf(respStatusCode));
        Log.i(TAG, "Response Header:");
        Log.i(TAG, rest.responseHeader());
        Log.i(TAG, "Response Body:");
        Log.i(TAG, sbResponseBody.getAsString());
        return;
        }


  }

  static {
      System.loadLibrary("chilkat");

      // Note: If the incorrect library name is passed to System.loadLibrary,
      // then you will see the following error message at application startup:
      //"The application <your-application-name> has stopped unexpectedly. Please try again."
  }
}