How to Update the transition in JIRA?

I am automating our release process by integrating our build software to update the transition in  JIRA system.

I am using C# widows application with JIRA SDK. I am able to update every other fields but transition.

So I tried updating transition with Postman by posting below code through APIs:

{
"update": {
"comment": [
{
"add": {
"body": "This is included in XX.06 Version."
}
}
]
},
"transition": {
"id": "211"
}

}

 

But no luck.

 

I am using windows app with C#.

Could anyone help me out. 

Thanks in advance.

2 answers

0 votes
Warren Levy Community Champion Nov 16, 2017

Hi Kamal

When I transition an issue, the JSON looks like this

{
"update": {},
"transition": {
"id": "241"
},
"fields": {
"resolution": {
"name": "Done"
}
}
}

So it's the resolution section which is different - try adding that

Thanks for your reply Warren.

I added the code what you suggested and tried posting using 'Postman'. With 'no authentication' as well as 'Basic Authentication',

In both the case i am getting 'Unauthorized 401' error.

Could you please guide me step by step or any link where i can get these details.

Thanks in advance.

You need to provide authenications data in the header. You should add to the header Authorization parameter with value "Basic <encodedBase64String>"

encodedBase64String= Base64.encode("username:password").

Read more here about it

https://developer.atlassian.com/jiradev/jira-apis/about-the-jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-basic-authentication

Hi Alexey,

Thanks for your response.

I tried the way you have suggested but still i am getting same  'Unauthorized 401' error.

Here is code snippet i am trying to run from my app using C#.

var client = new RestClient("http://jira2.test.com/rest/api/2/issue/test/transitions");
var request = new RestRequest(Method.POST);
request.AddHeader("postman-token", "864f9baf-c18b-7eeb-6329-b36e8c5cf726");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("Authorization", "Basic dGVzdDp0ZXN0");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "\r\n{\r\n \"update\": {},\r\n \"transition\": {\r\n \"id\": \"211\"\r\n },\r\n \"fields\": {\r\n \"resolution\": {\r\n \"name\": \"Done\"\r\n }\r\n }\r\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

 

I am getting following response  in body section:

<body id="jira" class="aui-layout aui-style-default page-type-message" data-version="7.1.1" >
<div class="aui-page-panel">
<div class="aui-page-panel-inner">
<section class="aui-page-panel-content">
<header class="aui-page-header">
<div class="aui-page-header-inner">
<div class="aui-page-header-main">
<h1>Unauthorized (401)</h1>
</div>
<!-- .aui-page-header-main -->

</div>
<!-- .aui-page-header-inner -->
</header>
<!-- .aui-page-header -->
<div class="aui-message aui-message-warning warning">
<p>Encountered a
<code>&quot;401 - Unauthorized&quot;</code> error while loading this page.
</p>
<p>
<a href="/secure/MyJiraHome.jspa">Go to JIRA home</a>
</p>
</div>
</section>
<!-- .aui-page-panel-content -->

</div>
<!-- .aui-page-panel-inner -->
</div>
<!-- .aui-page-panel -->
</body>

 

Any idea why its happening?

I am able to change the transition manually in JIRA site. So there is no question of authorization. Something else i am missing in this.

I forgot to ask. Do you use basic authentication in Jira? Sorry, I had to begin with the question.

No problem. Yes  i do have basic authentication in JIRA.

Could you execute a simpler script

var client = new RestClient("http://jira2.test.com/rest/rest/api/2/project");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Basic dGVzdDp0ZXN0");
request.AddHeader("content-type", "application/json");
IRestResponse response = client.Execute(request);

Your response must return information about projects 

Thanks Alexey for your response.

I still got same error. 

The transition may be commited under the conditions:

1. You have transition from the current status to the planned.

2. You have to fill all required fields on transition screen.

3. All validators have been passed.

So check that you a really have transition "id": "211" from the current status, all required fields have been filled and all validators have been passed.

Hi Gregor,

Thanks for your response.

I tried updating all the fields and also my transition id is correct. And validators are passed.

Still i got the same error.

Suggest an answer

Log in or Join to answer

Stay in touch

Be the first to know what's trending on Atlassian Community