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

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.?

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?

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.

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

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 18, 2018 in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

25,452 views 2 7
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