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

0 votes
Accepted answer

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!!!

Hi Menga

  I'm new to the whole thing ( JSON, JQUERY, AJAX,etc..,) but I'm technically capable of understanding how things work once I see the code.

Would you kind enough to give me the whole JavaScript file ( a simple sample will do ) where you make the API call to Jira?

1 - How the HTML file looks like?

2 - How the JavaScript looks like?

3 - Did you need to provide the user credentials (<userID>:<password> in base 64 basic authentication)?  If you did, then how did you do that? If you don't, then how did your Jira allow you to retrieve the user data?

I'm trying to build an example where my javascript will make API calls to my Jira.  Once I get the returned result in JSON  format I can parse the result and pump the data to an HTML running on my local HTML.

Thanks a lot for your help


PS: you could email me your sample code to my email:

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 Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

812 views 3 9
Read article

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