How do we fetch data through REST service which is hosted in window azure, from SharePoint site which in office 365? Can we need to create app for SharePoint which contain restAPI endpoint or any better solution than this?
1 Answer
You need to allow CORS to be able to do this. The problem is that javascript doesn't allow cross domain calls, and the Azure service can't have the same domain name as your Office 365 (At least I'm pretty sure of this).
By enabling CORS support in your Azure REST API, you can circumvent this. Do be warned however, that CORS must be supported by the browser too. I know there's some different behaviour between IE and other browsers in this regard.
Creating a SharePoint app actually also creates a new (sub)domain, so it won't work.
https://azure.microsoft.com/en-us/documentation/articles/app-service-api-cors-consume-javascript/
-
-
Hi Christoffel, here, RESTAPI which hosted on azure using httpwebrequest(c#) to get data from SharePoint online. In this case also will CORS work? Thanks in Advance.. Apr 23, 2016 at 15:41
-
Thanks eirikb, @user21853 C# will always work, CORS is not necessairy. Apr 23, 2016 at 16:29