How to Update the transition in JIRA?

kamal kumar das November 16, 2017

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.

3 answers

0 votes

Sorry to ask a dumb question, but does the user you're authenticating as have project_admin scope? It appears from the doco you have to have that to make transition changes to an issue, but you can create the issue with just the create scope just not transition it.

I will comment that I'm fighting with a similar problem at the moment, so I could well be wrong.

0 votes
Gregor Kasmann_Actonic
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 16, 2017

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.

kamal kumar das November 16, 2017

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.

0 votes
Warren
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 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

kamal kumar das November 16, 2017

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.

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 16, 2017

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

kamal kumar das November 16, 2017

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.

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 16, 2017

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

kamal kumar das November 16, 2017

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

Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 16, 2017

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 

kamal kumar das November 16, 2017

Thanks Alexey for your response.

I still got same error. 

Suggest an answer

Log in or Sign up to answer