JIRA HipChat集成插件有这个REST调用,我无法从我的插件中成功调用:
AJS.params.baseURL +“/rest/hipchat/compatibility/1.0/issuepanel/data /”+ issueId +“。json
此调用可以为我提供我正在寻找的HipChat会议室URL的部分,如果我是从REST浏览器创建的,或者即使我将其粘贴到浏览器的地址栏中,它仍然会给我JSON。但我需要从我的插件中调用此调用,在这种情况下它总是出错,即转到错误:AJAX调用部分。请提供您对此的意见 - 是否有任何其他插件进行REST调用的响应?
代码方面,我基本上是在调用我创建的这个函数:
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;
}
在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);
但我发现它总是执行错误:上面的AJAX调用部分并返回“ 没有配置此问题的Hipchat房间“
请尽快通知。