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