I'm developing a SharePoint2013 application in which I can only use Client Scripts (such as JQuery). I have to show list of JIRA issues assigned to the current logged on user. The app is deployed to a different hos than SharePoint so, I need to make a cross domain script call (JSONP). I have tried a lot of different things including the one below and non of them has worked. Please let me know what should I do to make this call?
BTW, I have tried the parameters used for $.ajax({}) in curl and it's returning expected response. it's just the usage of jsonp (perhaps) that is not right in my code (below):
Thanks in advance
$( '#ajax').click(function () { $.ajax({ type: "GET", "Content-Type": "application/json", dataType: "jsonp", url: "https://brcmdemo.atlassian.net/rest/api/2/issue/DEMO-1", success: function (data) { alert( "hello there!"); alert(data) }, error: function () { alert( 'failed'); }, beforeSend: function (xhr) { xhr.setRequestHeader( "Authorization", "Basic a2F0aWVqOnBhc3NAd29yZDE="); } }); }); });
Hello Everyone !!!,
I am facing issue in JIRA rest call using jquery in my web application . Below is the sample code that i have used. Below sample code giving following error
Refused to execute script from 'https://test.atlassian.net/rest/api/2/serverInfo?jsonpcallback=jQuery17105837092609144747_1440226296872&_=1440226299980' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
$.ajax({ url: 'https://test.atlassian.net/rest/api/2/serverInfo', dataType: 'jsonp', jsonp: 'jsonpcallback', beforeSend: function (xhr) { xhr.setRequestHeader("Authorization", "Basic username:password in encode form); }, }); function jsonpcallback(data) { alert('inside jsonpcallback'); }
I tried this way..
var data= {
"username": "myusername",
"password": "mypassword"
};
$.ajax({
url: https://XXXXXXX.atlassian.net/rest/auth/2/session,
type: POST,
dataType: 'jsonp',
jsonp: 'jsonp-callback',
data: data,
crossDomain: true,
success: function (data) { alert('success!' + data); },
error: function (data) { alert("error!!" + data); }
});
Now i get 404 not found error. in version 2
But Version 1 was returning 415 unsupported media type.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Make sure your dataType is 'jsonp' and jsonp param is 'jsonp-callback'. This works with version two api (https://[yourSubDomain].atlassian.net/rest/api/2/)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you have stumbled on the known limitation of JSONP - it does not handle 401 errors.
You can read about it here: http://forum.jquery.com/topic/jquery-ajax-with-datatype-jsonp-will-not-use-error-callback-if-request-fails
There are several ways of resolving it. One of them is using timeout:
http://www.haykranen.nl/2011/02/25/jquery-1-5-and-jsonp-requests/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.