0

I'm trying to fetch all subsites (just those at the root level, not sub-subsites, etc.). But, I suspect due to volume (4,000+ subsites), the following times out.

clientContext.Load(
    clientContext.Web.Webs,
    w => w.Include(s => s.Url),
    w => w.Include(s => s.RoleAssignments));
await clientContext.ExecuteQueryAsync();

I've tried increasing the timeout by setting clientContext.RequestTimeout = 600000;, but then instead of timing out, the query eventually results in error: The remote server returned an error: (503) Server Unavailable.

Is there some way I can paginate the results, or another way I can fetch a list of subsites that won't result in a timeout?

  • try with clientContext.RequestTimeout = -1 – TARUN Apr 5 at 4:26
0

Increasing the RequestTimeout property on the context can help, but it can only go so far before you come up against HTTP 503 errors. I still don't know how to page results, but something that significantly improves performance is to greatly limit the number of fields included in the result, like:

projectContext.Load(
    project.Web.Webs,
    w => w.Include(s => s.Url));
await _pwaContext.ExecuteQueryAsync();

Using this method, I retrieved 4,300 projects in less than a second, whereas not specifying the limited set of properties by using Include(..) would usually fail.

-1

Have you tried this extension?

You can install it via Nuget Install-Package SharePointPnPCoreOnline -Version 3.8.1904

It extends the ClientContext object and

Executes the current set of data retrieval queries and method invocations and retries it if needed.

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review – Ganesh Sanap Apr 19 at 13:37
  • Updated my anwser – Jack Le Apr 25 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.