O365 Exchange Rest API not working from jQuery

%3CLINGO-SUB%20id%3D%22lingo-sub-11205%22%20slang%3D%22en-US%22%3EO365%20Exchange%20Rest%20API%20not%20working%20from%20jQuery%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-11205%22%20slang%3D%22en-US%22%3E%3CP%3EO365%20Exchange%20REST%20api%20not%20working%20when%20invoking%20from%20jquery%2Fjavascript.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EHere%20is%20a%20rest%20api%20documentation%3A%20%3CA%20href%3D%22https%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Foffice%2Foffice365%2Fapi%2Fcalendar-rest-operations%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmsdn.microsoft.com%2Fen-us%2Foffice%2Foffice365%2Fapi%2Fcalendar-rest-operations%3C%2FA%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EI%20am%20trying%20to%20display%20my%20O365%20exchange%20calendar%20events%20using%20jquery%20on%20SharePoint%20Landing%20Page.%20Keep%20in%20mind%20that%20this%20will%20be%20come%20CORS%20call%20and%20hence%20I%20am%20using%20JSONP.%3CBR%20%2F%3Ebut%20this%20is%20throwing%20%22unexpected%20token%22%20response%20in%20the%20result.%20I%20see%20the%20response%20via%20fiddler%20but%20it's%20just%20not%20able%20parse%20it.%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CSTRONG%3ESample%20Code%3A%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%24.ajax(%7B%3CBR%20%2F%3Eurl%3A%20%22%3CA%20href%3D%22https%3A%2F%2Foutlook.office365.com%2Fapi%2Fbeta%2Fusers%2Fme%2Fcalendarview%3FstartDateTime%3D9%2F5%2F2016%26amp%3BendDateTime%3D9%2F10%2F2016%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Foutlook.office365.com%2Fapi%2Fbeta%2Fusers%2Fme%2Fcalendarview%3FstartDateTime%3D9%2F5%2F2016%26amp%3BendDateTime%3D9%2F10%2F2016%3C%2FA%3E%22%2C%3CBR%20%2F%3Etype%3A%20%22GET%22%2C%3CBR%20%2F%3EcrossDomain%3A%20true%2C%3CBR%20%2F%3EdataType%3A%20%22jsonp%22%2C%3CBR%20%2F%3Ejsonp%3A%20false%2C%3CBR%20%2F%3E%3CBR%20%2F%3Esuccess%3A%20function%20(data)%20%7B%3CBR%20%2F%3Econsole.log('hello')%3B%3CBR%20%2F%3E%3CBR%20%2F%3E%7D%2C%3CBR%20%2F%3Eerror%3A%20function%20(xhr%2C%20status)%20%7B%3CBR%20%2F%3Econsole.log(%22error%22)%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D)%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

O365 Exchange REST api not working when invoking from jquery/javascript.


Here is a rest api documentation: https://msdn.microsoft.com/en-us/office/office365/api/calendar-rest-operations


I am trying to display my O365 exchange calendar events using jquery on SharePoint Landing Page. Keep in mind that this will be come CORS call and hence I am using JSONP.
but this is throwing "unexpected token" response in the result. I see the response via fiddler but it's just not able parse it.


Sample Code:

$.ajax({
url: "https://outlook.office365.com/api/beta/users/me/calendarview?startDateTime=9/5/2016&endDateTime=9/10...",
type: "GET",
crossDomain: true,
dataType: "jsonp",
jsonp: false,

success: function (data) {
console.log('hello');

},
error: function (xhr, status) {
console.log("error");
}
});

0 Replies