Wednesday, 12 April 2017

Update JIRA issue status wıth nodejs

I want to update JIRA issue status. What have I done so far?

Firstly I get the transition ids with;

https://hostname/rest/api/2/issue/{issueKey}/transitions

This returned me(shorten form);

{
   "expand":"transitions",
   "transitions":[
      {
         "id":"11",
         "name":"To Do"
      },
      {
         "id":"21",
         "name":"In Progress"
      },
      {
         "id":"31",
         "name":"In Review"
      },
      {
         "id":"41",
         "name":"Done"
      }
   ]
}

To be able to do the transition;

var url = "https://hostname/rest/api/2/issue/{issueKey}/transitions";
var message = [{
    "update": {
        "comment": [
            {
                "add": {
                    "body": "comment"
                }
            }
        ],
        "worklog" : [
            {
                "add": {
                    "timeSpent" : "timeSpent"
                }
            }
        ]
    },
    "fields": {
        "resolution": {
            "name": "To Do"
        }
    },
    "transition": {
        "id": "11"
    }
}];
request({
    url: url,
    method: "POST",
    json: true,
    body: message
}, function (error, result){
    if(error){
        nresponse.error(res, error);
    }else{
        console.log(result);
    }
});

This code snippet doesn't throw an error. Actually it returns successfully. But when I check the status, comment section of the issue, I see that nothing has changed. What am I missing? How can I update the JIRA issue status with node.js?

console.log(result); 

returns as;

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Connect Error</title>
</head>
<body>

<div id="pagecontainer">
        <h1>Could not connect to server</h1>

        <div class="row">
                <p class="label">Overview:</p>
                <p class="item">Could not connect to hostname.</p>
        </div>
        <div class="row">
                <p class="label">Details:</p>
                <p class="item">The remote side uses a protocol version that is not enabled</p>
        </div>

        <div id="options">
                <p class="label">Options:</p>
                <form action=""><input type="button" class="button" onclick="history.back();" value="   Go Back   "></form><p class="item">Pressing the button allows you to go to the previous page.</p>
                <p class="last-item">You can try to reload the page or check if the URL is correct.</p>
        </div>

                <div style="clear: both; overflow: hidden; height:1px;"></div>
        </div>
</div>

</body>
</html>

What is the meaning of this result?



via mmu36478

No comments:

Post a Comment