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.
Community moderators have prevented the ability to post new answers.
var issueKey = AJS.Meta.get("issue-key"); if (issueKey) { return AJS.$.ajax({ url: AJS.contextPath() + "/rest/hipchat/integrations/1.0/issuepanel/data/" + issueKey, cache: false, dataType: 'json', type: "GET" }).done(function (data) { // You get the data here }).fail(function (jqXHR, textStatus) { // Here the failing thing }).always(function() { });
The REST url is:
AJS.params.baseUrl + "/rest/hipchat/integrations/1.0/issuepanel/data/" + issueId
There is no ".json" in the end.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Never worked with HipChat REST but have a feeling that your REST call needs authentication. Calls from REST browser or direct calls from browser already have authentication cookies.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Volodymyr Krupach , what kind of authentication would be needed if I have to make that call from the server side Java code, such that it shows the same behavior as the REST API Browser? In general, lets say one JIRA plugin has some REST calls and I need to call those from SERVER side (a.k.a, from Java code), could you please advise on how should I go about taking care of authentication? It will also help if u have some code snippet to guide
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.