Unable to update the status using api node js

Karthikeyan N November 15, 2018

I am trying to update the status of the bug using api node js but it is not getting updated.

var bodyData =

{ "update":

{ "summary": [ { "set": "Issue Updated" },],

"status": [{ "statusCategory": { "name": "DONE" } }]

}}

try {

var options = {

url: url

method: "PUT", json: true,

headers: { 'Authorization': 'Basic ' + new Buffer(username + ':' + password).toString("base64"), 'X-Atlassian-Token': 'nocheck',

'Content-Type': 'application/json' }, body: bodyData };
request(options, async function (error, response, body) { if (error) { console.log(error); //return response.statusCode; } else { console.log(body); } });

} catch (e) { console.log(e);}

1 answer

0 votes
Nic Brough -Adaptavist-
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 15, 2018

You can't update an issue status with a simple edit action.  You need to tell the API to transition the issue through a transition from its current status to the desired one.

Karthikeyan N November 15, 2018

Thanks for the reply. Can you please provide the sample API for transistion

Karthikeyan N November 15, 2018

Used transistion but still it is not working throwing error as ["Transition id '6' is not valid for this issue."],"errors":{"comment":"Field 'comment' cannot be set. It is not on the appropriate screen, or unknown."}}

if used any id also it is not working. Please help me on this

var bodyData =

{ "update":

{ "comment": [ { "add": { "body": "Fixed." } } ] },

"transition": { "id": "6" }}

try {

var options = {

url: 'https://name.atlassian.net/rest/api/3/issue/TEST-5/transitions',

method: "POST",

json: true,

headers: { 'Authorization': 'Basic ' + new Buffer(username + ':' + password).toString("base64"),

'X-Atlassian-Token': 'nocheck',

'Content-Type': 'application/json' },

body: bodyData };


request(options, async function (error, response, body)

{ if (error) { console.log("error"+error);

} else { console.log("body"+JSON.stringify(body)); } });

} catch (e) { console.log(e);}

Nic Brough -Adaptavist-
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 17, 2018

It sounds like the issue is in a status which does not have a transition with id 6 out of it.   The comment won't apply because there's no screen for the transition for it (because there's no transition)

Karthikeyan N November 20, 2018

Can you please provide the sample node js api for changing the status of the issue.

Nic Brough -Adaptavist-
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 20, 2018

The API you are using is the REST API - see https://developer.atlassian.com/server/jira/platform/rest-apis/ for the definition.

However, I don't think there's much (if anything) wrong with your code.  The problem is that you're trying to use a transition that isn't there.

Suggest an answer

Log in or Sign up to answer