Can't Use Json to Access JIRA API


I am developing a standalone gadget for JIRA with HTML and JavaScript. In which I wish to use json to get the username of current via REST API and owner of dashboard to realize the authorization.

According to

I use a similar way to access the database. Nevertheless it does not work - the success function never works.

For the url, I use the whole name - i.e. http://.../currentUser, which could actually work via XMLHTTPRequest - but with XMLXttpRequest I could not fetch the value of a single field....So it is not usable.

Could you please help me to answer this question?


2 answers

1 accepted

There is the problem: According to the official cite, AJAX is not supported in JIRA any more. So to deal with this issue, I use jQuery instead.

To use the jQuery syntax, simply include this line before any other scripts in the file.

<script src="" type="text/javascript"></script>

Then, I implement the functionality in the following way:

      alert("I am here");

The usage is referred from

Finally it works!!!!!

P.S. Chrome's Javascript Console is so useful! Highly recommended!!!

i think you are trying to get current login user name

if yes then try with following code

jQuery(document).ready(function() {
	AJS.$.get("/jira/rest/auth/1/session", function (data) {	
		var userName =;		

Hi, thank you for your answer!

I have tried but it does not work as is the code:

function getCurrentUserName()
alert("function begins!");
var userName;
  jQuery(document).ready(function() {
      AJS.$.get("http://ltsjc-monadu:2990/jira/rest/auth/1/session", function (data) {  
          userName =;     
return userName;

is it triggering javascript function?

are you getting any error message?

which version of jira you are using?

yep, it is in JavaScript. But I did not get any error message... I believe it is JIRA 5.1.7. Oh you just reminded me to test it in HTML rather than Gadget. Let me try it and then post the follow-up.


Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,241 views 14 19
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot