Posts

Showing posts from April, 2017

Get Host site list items in SharePoint Hosted App.

Those who starts working on Apps might face issues to read host site list items. In sharepoint hosted APP using Rest API we able to query host site list items. The rest url to get host site is almost similar to get list items but we need to specify the app context and target. Make sure JQuery loaded before to execute the code in app web parts. 'use strict'; var HostUrl=""; var AppUrl==""; // load function // Intialize HostUrl, AppUrl from query strings. // call get items method $(document).ready(function () {         HostUrl= GetQueryString("SPHostUrl");        // Get Host Url from query string         AppUrl= GetQueryString("SPAppWebUrl");        // Get App Url from query string getItems("DemoList");                                        // get list items }); // function to get list items using Rest Api function getItems(listname) {             $.ajax({                 url: AppUrl + "/_