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

Swaraj gochhayat January 28, 2013

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 votes
Renjith Pillai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 28, 2013

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

It may help you.

Swaraj gochhayat January 29, 2013

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

Renjith Pillai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 29, 2013

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

Swaraj gochhayat January 29, 2013

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 29, 2013

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

Swaraj gochhayat January 29, 2013

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 2, 2013

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

Suggest an answer

Log in or Sign up to answer