SharePoint 2013 apps - communicate with host SharePoint without using SP.RequestExecutor

In a previous post I wrote an app to read and write data from the Host-SharePoint. To do this I made use of the SP.RequestExecutor. This class is used to get the permissions for reading and writing data into the Host-SharePoint. But there is a way to skip the authentification and using the URL directly. This makes your code much more beautiful and easy to read. All you need to do is to call a function (_spPageContextInfo.siteAbsoluteUrl). That function returns an URL and makes it possible to communicate with the SharePoint per JSOM and REST.  I also tried to call the URL with the function and make a context with another URL and this does not work. Even the Host-URL does not work. Another disgusting point is that the URL, which is returned by the function, is that it not contains the URL of the app and not of the host. It is a 'hybrid' that begins like the app URL, but ends earlier.

1
2
3
4
var url = _spPageContextInfo.siteAbsoluteUrl;
context = new SP.ClientContext(url);
web = context.get_web(); 
context.load(web);

Comments

Popular posts from this blog

How to support multiple languages in WPF