Hi,
I have a sharepoint provider hosted app with the following code, the app works fine the way it is but I am experiencing issues with the server returning "429 - Too many requests" and to try and get around the problem I am revisiting my code to see if I can find more efficient ways of running it. Does anyone know how I can perform the following without having to run "clientContext.ExecuteQuery()" in the "foreach" statement?
// Get all lists
ListCollection lists = clientContext.Web.Lists;
clientContext.Load<ListCollection>(lists);
clientContext.ExecuteQuery();
// Get sharepoint url without trailing backslash
string sharepointUrlNoBackSlash = VirtualPathUtility.RemoveTrailingSlash(sharepointUrl.ToString());
// Loop through lists
foreach (List list in lists)
{
clientContext.Load(list, l => l.DefaultViewUrl, l => l.EffectiveBasePermissions, l => l.ImageUrl);
clientContext.ExecuteQuery();
// If list is specified in list ids and user has permission to view list
if (listIdGuids.Contains(list.Id) && list.EffectiveBasePermissions.Has(PermissionKind.ViewListItems))
{
// Create document library object
SharepointList dl = new SharepointList();
dl.Title = list.Title;
dl.DefaultViewUrl = sharepointUrlNoBackSlash + list.DefaultViewUrl;
// Add to list
documentLibraries.Add(dl);
}
}