Resolved: SharePoint CSOM: what does loading ClientContext.Site do?

In this post, we will see how to resolve SharePoint CSOM: what does loading ClientContext.Site do?

Question:

Background: I’m responsible for a connector program I’ve inherited that indexes a customer’s SharePoint sites. On production at the customer’s premise, SharePoint CSOM is always returning 429. I’ve implemented all the measures to prevent throttling, but it doesn’t help. The only possibility left is that somehow I’m requesting too much.
At the start of my program, after authentication, I’ve got the following:
Where the Load() function does this:
Now, my question is: what does this do/request? I haven’t found any documentation or example about loading ClientContext.Site. All the examples I’ve found immediately load ClientContext.Web.

Best Answer:

This loads all properties of a site collection. The terminology may be confusing because it originates from the times when there were terms “site collection” (“site”) and “site” (“web”). Yes, it is confusing, but that’s how it is… You can find the documentation on ClientContext.Site on the Microsoft website
Anyway, the number of site collection properties is quite limited, so this can hardly be a reason for you getting the 429 error.
If you see 429 error, then probably you do not implement rate limiting properly. Check out this article and demo on throttling by Microsoft: https://devblogs.microsoft.com/microsoft365dev/prevent-throttling-in-your-application-by-using-ratelimit-headers-in-sharepoint-online/

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com