Question

Is there a way to get all the lists in the subsites where the list is named 'Posts'? This gets the list if it is deployed on the subsite itself but not from the parent. The hostUrl looks like 'http://contoso/' I need it to look like 'http://contoso/site/blog', the AppPart will be deployed on the parent and I want it reusable so I can publish it to the local SharePoint Store.

var appUrl = GetUrlKeyValue("SPAppWebUrl");
var hostUrl = GetUrlKeyValue("SPHostUrl");

var url = appUrl +
      "_api/SP.AppContextSite(@target)/web/lists/getbyTitle('Posts')/items?" +
      "$select=ID,Title,Body,NumComments,Published&$orderby=Published&" +
      "@target='" + hostUrl + "'";
Was it helpful?

Solution

It is definitely a mess but I figured it out. I decided to just use a app property eventually and make the user enter the url, but here's the answer for the above.

 var blogUrl = appUrl + "/_api/site/rootWeb/webinfos?$filter=(WebTemplate%20eq%20'BLOG')";

That will get all the blog sub sites and from within that you can iterate through and get all the blogs' Post lists.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top