How can i be able to get the response of an JIRA API call using cross domain GET or POST request.?

I am using Jquery for the above requirement.

$.ajax({

type: 'GET',

url: 'https://--------------/rest/auth/1/session'',

crossDomain: true,

dataType: 'jsonp',

success: function (response) {

alert('success--' + response);

},

error: function (response) {

alert('oopss!!');

}

});

I am able to see the response in debugger in JSON format but i have to use dateType: jsonp due to cross domain request, else it throws error 415: Unsupported MediaType

So I get the following errors when i run the script:

SyntaxError: invalid label in Mozilla.

Uncaught SyntaxError: Unexpected token : in Chrome

Please help.

Where am i going wrong.?

Thanks in advance.

1 answer

0 vote
Renjith Pillai Community Champion Jan 28, 2013

See the way jsonp is invoked for JIRA here http://jsfiddle.net/rmanalan/rtvF6/

It may help you.

IT shows for GET requests. If i make any POST requests i get 415 unsupported mediatype error. Any suggestions regarding that.?

Renjith Pillai Community Champion Jan 29, 2013

What's the post header being set? Check your developer tools in Chrome and see the header being sent

I get the post header :

Content-Type text/html;charset=utf-8
Date Wed, 30 Jan 2013 13:59:46 GMT
Server nginx
Set-Cookie JSESSIONID=AEAF6C3853868EB6920629F486A19C8A; Path=/; HttpOnly studio.crowd.tokenkey=""; Domain=.skalable.atlassian.net; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly studio.crowd.tokenkey=qrk1dL4vKHcyOpspelmDDg00; Domain=.xxxxxx.atlassian.net; Path=/; HttpOnly atlassian.xsrf.token=B9V3-S7DT-R7Y6-F32Y|3bfef2a642091fb9bff59acb496616e7fd3b4aab|lin; Path=/
Vary Accept-Encoding
X-AREQUESTID 359x10274x1
X-ASESSIONID 197bgpo
X-AUSERNAME swaraj
X-Seraph-LoginReason OUT, OK


Is there anything wrong with the header being set?

Renjith Pillai Community Champion Jan 29, 2013

Yeah, it shows ' Content-Type text/html' It should be application/json

Yes, i am sending it through jsonp, since json wont support cross domain calls.
If i use application/json the post request changes to OPTION.

Renjith Pillai Community Champion Feb 02, 2013

Ah ok. No idea, never used jsonp with JIRA.

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,293 views 14 20
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