Unable to use JiraRestClient or rest api to transition issues through workflow

I am trying to transition issues through the workflow using either the JiraRestClient or rest directly.

I have successfully used a combination of both to facilitate creating issues and sub-tasks and searching for issues and sub-tasks.

When attempting to transition an issue I am getting back

Request failed-Http Status: POST https://<our-host>.com/rest/api/latest/issue/QA-10109/transitions returned a response status of 400 Bad Request

Using curl

curl -v -X POST -H "Content-Type:application/json" https://<our-host>.com/rest/api/latest/issue/QA-10109/transitions --user "me:pw" --data-ascii @data.txt

Response:

{"errorMessages":["Can not deserialize instance of java.util.ArrayList out of START_OBJECT token\n at [Source: org.apache.catalina.connector.CoyoteInputStream@716ca6c8; line: 1, column: 15]"]}

data.txt contents

{"update": {

"transition": {"name": "RerunPass"},

"comment": [{"add": {"body": "BuildID: 20121022-14000-2222222\nSystem: \nVersion: 2012 Q3\nTell me more"}}],

"fields": {"resolution": {"name": "RerunPass"}}

}}

any assistance in debugging this or examples of using either the direct rest access or JiraRestClient would be appreciated.

2 answers

1 accepted

1 vote
Penny Wyatt Atlassian Team Oct 24, 2012

Hi Gail! You're nearly there, there's just two minor issues with the contents of data.txt:

1) "transition", "comment" and "fields" are underneath "update", but only "comment" should be. "transition" and "fields" should be on the same level as "update".

2) transitions need to be to be referenced by ID, not name (names aren't necessarily unique). You can get the transition IDs by sending a GET request to the same URL.

Here's the modified version of your data.txt that works against my test instance:

{
	"update": {
		"comment": [
			{
				"add": {
					"body": "BuildID: 20121022-14000-2222222\nSystem: \nVersion: 2012 Q3\nTell me more"
				}
			}
		]
	},
	"fields": {
		"resolution": {
			"name": "RerunPass"
		}
	},
	"transition": {
		"id": "5"
	}
}

Thank you. I'll fix that today. I am very happy with the new rest api. It is a vast improvement over the SOAP and old rest.

If you want to achive the same with JIRA REST Java Client, you may try that code (for JIRA5+):

// get issue
final Issue issue = client.getIssueClient().getIssue("QA-10109", pm);

// find transition (we need ID)
final Iterable&lt;Transition&gt; transitions = client.getIssueClient()
		.getTransitions(issue.getTransitionsUri(), pm);
		
final Transition transition = Iterables.find(transitions, new Predicate&lt;Transition&gt;() {
	@Override
	public boolean apply(Transition input) {
		return "RerunPass".equals(input.getName());
	}
});

// prepare fields
final List&lt;FieldInput&gt; fields = Arrays.asList(new FieldInput("resolution",
		ComplexIssueInputFieldValue.with("name", "RerunPass")));

// create comment
final Comment comment = Comment.valueOf(
		"BuildID: 20121022-14000-2222222\nSystem: \nVersion: 2012 Q3\nTell me more");

// do actual transition
client.getIssueClient().transition(issue,
		new TransitionInput(transition.getId(), fields, comment), pm);

Does this worked for you?

I will try this too. I like know more than one way to get it done.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,254 views 14 20
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot