The JIRA HipChat integration plugin has this REST call which I am unable to invoke successfully from my plugin:
AJS.params.baseURL + "/rest/hipchat/compatibility/1.0/issuepanel/data/"+issueId+".json
This call can give me the parts of the HipChat Room URL I am looking for , and if I make it from REST Browser, or even if I paste this in the address bar of my browser, it still gives me the JSON. But I need to make this call from my plugin , and in that case it always errors out i.e. goes to the error: section of the AJAX call. Please provide your input on this - is there any restrcition in making that REST call from any other plugin?
Code wise, I am basically calling this function I created:
function getHipChatRoomURL(issueId) {
console.log("Invoking get hipchat room URL");
var hipChatRoomURL = "";
var urlToGetHipchatRoom = AJS.params.baseURL + "/rest/hipchat/compatibility/1.0/issuepanel/data/"+issueId+".json";
console.log("Attempting to get the hipchat room URL thru this REST Call " + urlToGetHipchatRoom);
AJS.$.ajax({
url: AJS.params.baseURL + "/rest/hipchat/compatibility/1.0/issuepanel/data/"+issueId+".json",
dataType: "application/json",
async:false,
success: function(response) {
var apiUrl = response.dedicatedRoom.apiUrl;
var roomId = response.dedicatedRoom.roomId;
hipChatRoomURL = apiUrl+"/chat/room/"+roomId;
hipChatRoomURL = "<a href="+"\'"+ hipChatRoomURL+"\'"+">Join Hipchat Room</a>";
console.log("Hipchat room URL In AJAX Call is " + hipChatRoomURL);
return hipChatRoomURL;
},
error: function() {
hipChatRoomURL = "No Hipchat room configured for this issue";
return hipChatRoomURL;
}
});
console.log("Get hipchat room URL invoked");
return hipChatRoomURL;
}
And invoking this method like this under AJS.toInit() :
setTimeout(function() {
var issueKey = AJS.Meta.get("issue-key");
AJS.log("ISSUE KEY SENT to find the room URL is " + issueKey)
hipChatRoomURL = getHipChatRoomURL(issueKey);
console.log("Hipchat room URL is " + hipChatRoomURL);
},1000);
But I am seeing that it always executes the error: section of the AJAX call above and returns " No Hipchat room configured for this issue"
Please advise as soon as possible.