I am trying to create a script that hides a field if an issue is in a particular status. To get the status, I am making an ajax request to the Rest API. However, this request keeps failing and I'm not sure why.
The ajax request is as follows:
function getStatus() { var issueKey = JIRA.Issue.getIssueKey(); var restUrl = "/rest/api/2/issue/" + issueKey; var statusname; console.log('KEY : ' + issueKey); console.log('URL : ' + restUrl); AJS.$.ajax({ url: restUrl, type: 'get', dataType: 'json', contentType: "application/json", }) .done(function(data) { statusname = data.fields.status.name; console.log('Status Name : ' + statusname); return statusname; }) .fail(function() { console.log('ERROR'); }) .always(function(data) { console.log('DATA : ' + data); }); }
Could someone tell me why this is failing and where I've gone wrong? Alternatively, is there an easier/short-hand way to get the status of an issue?
Community moderators have prevented the ability to post new answers.
What HTTP status does it return? Is there respsonse body?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.