Forum Discussion
CSOM: My “one query to rule them all” plan backfired — got “Request uses too many resources” 😅
Hey folks,
So I’ve been playing around with CSOM (Client-Side Object Model), feeling fancy about making one super-efficient query that loads everything I need at once. Something like this:
clientContext.Load( clientContext.Web, w => w.SiteUsers.Include(...), w => w.Lists.Include(...), w => w.SiteGroups.Include(...) );
Basically, my thought was: “Why make multiple calls when I can just get everything in one go?”
But CSOM had other plans. Instead of being impressed, it hit me with the dreaded:
"Request uses too many resources."
Even when I tried to be nice and limit the properties, it still said “Nope.” 🙃
So now I’m wondering:
Is it actually more efficient (and safer) to create a new ClientContext for each object I want to query (like Web, SiteUsers, Lists, etc.)?
Or am I just thinking about this the wrong way and missing some batching trick?
Would love to hear how others handle this — or if there’s a secret sauce to making CSOM not freak out when you ask for too much.