0

I want to get the "Site Usage Report" on a Sharepoint Online site using C#. How can I do it? This link provides solutions to get these details but I want to do it programatically using C# (CSOM).

Another question along the similar lines was asked in the past, but I believe it wasn't answered satisfactorily.

0

The following code retrives the Usage Info but sadly, the Hits and Visits shows 0 because of this reason.

clientContext.Load(clientContext.Site, s => s.Usage);
                try
                {
                    clientContext.ExecuteQuery();

                    UsageInfo usageInfo = clientContext.Site.Usage;
                    usageData = "No. of hits: " + Convert.ToString("" + usageInfo.Hits) + "; ";
                    usageData += "No. of visits: " + Convert.ToString("" + usageInfo.Visits) + "; ";
                    usageData += "Storage: " + Convert.ToString("" + usageInfo.Storage) + "; ";
                    usageData += "Storage Percentage Used: " + Convert.ToString("" + usageInfo.StoragePercentageUsed) + "; ";

                    var bytes = usageInfo.Storage;
                    Debug.Print("UsageData " + usageData);
                    Debug.Print("Bytes " + bytes);
                }

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.