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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

Meet the AUG leaders of Northern Virginia

@Rachel Wright (Jira Genie), @Billy Poggi (AUG NOVA, DC), and @Dana Jansen (Confluence Queen) are just some of the folks that lead one of the world's most active Atlassian User Group (AUG)....

121 views 4 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