1

I have a collection in our SPO setup which contains 500+ subsites. Each subsite contains between 10 and 20 libraries.

I have been tasked to get data on which folders in which library is empty. I've written a small javascript using the REST api to first and foremost gather the amount of files within each library - however if I run this on all 500+ subsites my user gets locked out due to hitting with too many requests.

Does anybody know an alternative way to get the information i need? I don't suppose there's any REST endpoint returning all files across a (sub)site with their (relative) path?

1

This is correct way (using REST) of doing it. You need to just adjust your code.

You are hitting throttling limits. You need to carve your code in such a way that it doesn't send too many request at the same time. Give it some wait time between each call etc. It means you code will run longer but it will not be throttled.

Have a look at this general guidance from MS: https://docs.microsoft.com/en-us/sharepoint/dev/general-development/how-to-avoid-getting-throttled-or-blocked-in-sharepoint-online

  • Thanks I was considering this, but we're talking north of 10K requests. Even a 1 second delay for each library will have it running for close to 3 hours? – Morten K Apr 15 at 13:08
  • Yes and time will grow as you have more content. But you can set it to run on schedule from machine (maybe then it will be easier to use PnP PowerSHell) to run overnight. – Marek Sarad Apr 15 at 14:14
  • Hmm doesn't sound like the best approach to be honest :-/ – Morten K Apr 15 at 18:41

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.