I've been trying to get a Jira dashboard gadget to display in a confluence page, specifically the gantt chart from the Jira BigPicture plugin. Since the gadget when displayed in Confluence will vary depending on whether or not the user has been approved, my goal is to circumvent this feature.
What I've discovered is that using inspect element or a rest client to pull a page as an approved user will allow me to grab the code for a gadget that can be displayed. However, when I try to use javascript (using the confluence html macro), or a Java servlet, or use the REST api to pull the body.view code, I cannot seem to get the code to either authenticate as an approved user, or pull valid code.
Does anybody have any thoughts or approaches I can do?
Hi,
You can use Basic-Auth to call Jira REST API.
Assuming you are using jQuery to make an Ajax call, this should work if you use an autorized user account and their related password:
Use jQuery's beforeSend
callback to add an HTTP header with the authentication information:
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic " + btoa(username + ":" + password));
},
I've tried setting the authentication in the header of my ajax calls, but it seems like Confluence overwrites this when I make the request, as It appears that I'm still authenticated as the current user rather than the authorized user. It is still the case with with beforeSend.
Thanks for the new option though!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For context, here's the code I'm using to grab another page and insert it into an existing div.
<div id="test">
<p>
hi
</p>
</div>
<script>
$("#test").html("<p>getting gantt chart...</p>");
url = "http://localhost:8090/display/ds/gantt";
$.ajax({
url: url,
type: "GET",
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic " + btoa("admin" + ":" + "admin"));
},
}).done(function(data){
var start = data.search('<p><div class="gadgetContainer').toString();
var end = data.search('</iframe></div></p>');
//var mid = data.search('<a');
$("#test").html(data.substring(start, end+19) + "</iframe></div></p>");
console.log(data.substring(start, end+19) + "</iframe></div></p>");
//$("#test").html("<p>" + "dab" + "</p>");
}).fail(function (e){
$("#test").html("<p>Failed to get chart</p>");
});
</script>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.