Accesing sharepoint online from various clients

ぃ、小莉子 提交于 2019-12-25 18:07:42

问题


I have a sharepoint online site were I'm using announcements. These announcements I would like to consume in a Cordova app and also on a HTML5 site that I have on some info screens.

I have been looking into using the REST service and app for sharepoint.

Example:

var requestUri = 'https://site.sharepoint.com/_api/web/lists(guid\'someGuid')/items'; 
var requestHeaders = { 'accept': 'application/json;odata=verbose' }; 
$.ajax(
    { 
        url: requestUri, 
        contentType: 'application/json;odata=verbose', 
        headers: requestHeaders, 
        success: function (response){
            console.log(response);
        }, 
        error: function(error) {
            console.log(error);
    } 
 });

When I run this I get the: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

I know I can look into trying to enable CORS on sharepoint, or use JSONP.

I was wondering if the path I'm going down here are the correct path or would it be better to create my own WebService and get the data through that?

Any better ways?

thanks


回答1:


If your Sharepoint online is connected with Azure AD, then you can use Azure AD application access sharepoint REST API with CORS enabled. Follow the steps at https://msdn.microsoft.com/en-us/office/office365/howto/create-web-apps-using-CORS-to-access-files-in-Office-365



来源:https://stackoverflow.com/questions/26083657/accesing-sharepoint-online-from-various-clients

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!