Hello,
how can i retrieve the app list of my rootsite of site my site collection using javascript?
I wanna create an app wich display all app installed and not installed on the site collection where my app is installed..
regards
Technology Tips and News
Hello,
how can i retrieve the app list of my rootsite of site my site collection using javascript?
I wanna create an app wich display all app installed and not installed on the site collection where my app is installed..
regards
You can use the REST search api to get a list of all installed apps. Apps are basically sub sites which use the web template "APP". Your app will need to have the "Search - QueryAsUserIgnoreAppPrincipal" permission. The code below shows the REST syntax you could possibly use. To get a list of of apps that are in the catalog and not installed is probably not possible, especially in O365. In SharePoint you most likely will have to give users of your app full control of the site collection to see this list.
function doAppSearch() { var searchRestSource = decodeURIComponent(getQueryStringParameter("SPAppWebUrl")) + "/_api/search/query?querytext='" + "WebTemplate:APP'" + "&selectproperties='Path,Author,Title,LastModifiedTime'" + "&rowlimit=500" + "&trimduplicates=false" + "&enablequeryrules=true" try { $.ajax( { url: searchRestSource, method: "GET", headers: { "accept": "application/json; odata=verbose", }, success: function (data) { if (data.d.query.PrimaryQueryResult.RelevantResults.RowCount > 0) { var queryResults = data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results; }; }, error: function (err) { alert(JSON.stringify(err)); }, } ); } catch (err) { alert(JSON.stringify(err)); } }