You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use the subsite as context and then the subsite server relative url to get the subsite itself as folder (trying to replicate here the same as I see on PnP.PowerShell) and check the storage metrics.
I don't get any errors (if I use the Site collection as context, I do get errors), so I can assume the code is correct. But the 'TotalSize' property is always 0. It seems something is not loading correctly, or something is missing but doesn't bring errors.
Can anyone clarify if this is possible to do usin CSOM and how?
or in case only the REST API is feasible, how to make the call correctly to get the storage metrics?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello everyone,
I hope someone can point me out on the right direction here.
I'm trying to get the storage used by a subsite for my app on C#. I found PnP.PowerShell has a nice solution for this: https://pnp.github.io/powershell/cmdlets/Get-PnPFolderStorageMetric.html
Looking at the code, it use the Web object of the subsite to get the Folder object of itself containing the expresions "StorageMetrics"
https://github.com/pnp/powershell/blob/dev/src/Commands/Files/GetFolderStorageMetric.cs
PnP.PowerShell use directly PnP.Core for this task.
https://github.com/pnp/pnpcore/blob/dev/src/sdk/PnP.Core/Model/SharePoint/Core/Internal/Web.cs?#L395-L408
PnP.Core seems making calls to the API: _api/Web/getFolderByServerRelativePath(decodedUrl='{encodedServerRelativeUrl}')
I'm not sure how the PnP.Core add the expresions when calling the API or what additional info is required for the body. I only saw this information on regards this API: https://stackoverflow.com/questions/48500381/sharepoint-rest-api-getfolderbyserverrelativepath-returns-error-when-percent-sig
Meanwhile, I've tried to use directly CSOM to get the the storage metrics of the subsite as a folder: https://learn.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.client.web.getfolderbyserverrelativepath?view=sharepoint-csom
I use the subsite as context and then the subsite server relative url to get the subsite itself as folder (trying to replicate here the same as I see on PnP.PowerShell) and check the storage metrics.
I don't get any errors (if I use the Site collection as context, I do get errors), so I can assume the code is correct. But the 'TotalSize' property is always 0. It seems something is not loading correctly, or something is missing but doesn't bring errors.
Can anyone clarify if this is possible to do usin CSOM and how?
or in case only the REST API is feasible, how to make the call correctly to get the storage metrics?
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions