First of all, You must give the app read access to the Host Site Collection through the App Manifest file.

AppManifest.xml
AppManifest.xml

When the App first launches, SharePoint provides three values in the query string named: SPHostUrl, SPAppWebUrl and SPLanguage.

When the correct permission requests are set, we can use the SPHostUrl and SPAppWebUrl to connect to the SharePoint web services. This code snippet below gets the query parameters and loads the necessary SharePoint JavaScript files.

After the SharePoint JavaScript files are loaded, the appweburl is needed to create a context. With this context we can create a appContextSite to get to the host web.

For those of you who are REST purists, an example of doing the same thing is on the this Technet article Access SharePoint 2013 data from add-ins using the cross-domain library . But in my app, I’m using the Client Object Model and there really weren’t any examples out there that showed how to do this using CSOM.

About The Author

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Close