Microsoft Graph CSharp SDK and OneDrive for Business with a Service/Daemon application - Quota facet returns null

我与影子孤独终老i 提交于 2019-12-07 11:28:27

Thanks for reporting the issue. The quota and owner information was indeed not being returned for App Only calls if you had Files.Read.All or Files.ReadWrite.All scope in the token. I have fixed the issue and the fix should roll out to Production soon. As a workaround though, you can use Sites.FullControl.All scope for your app and that should return the quota and owner information.

The quota.used facet is not being returned by the service (I'll report this issue). You can use the total and remaining properties to determine the amount of used quota.

Update To answer your original question... Yes, the Microsoft Graph .Net Client library does support Quota and User on OneDrive for Business accounts.

I don't know why you aren't getting the quota returned in the response. I'm not familiar with OneDrive for Business quotas... Is it possible you don't have a quota? Just for the sake of being complete, I took your code:

var user = await graphClient.Users["user@test.onmicrosoft.com"].Request().GetAsync();
var drive = await graphClient.Drives["user@test.onmicrosoft.com"].Request().GetAsync();
var quotaTotal = drive.Quota.Used;
var displayName = user.DisplayName;
var driveType = drive.DriveType;
var driveId = drive.Id;

I successfully got back a quota object without the used property. Here's what I see in the response.

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives/$entity",
    "id": "<some ID>",
    "driveType": "business",
    "owner": {
        "user": {
            "id": "<some ID>",
            "displayName": "user"
        }
    },
    "quota": {
        "deleted": 4155859,
        "remaining": 1099484034353,
        "state": "normal",
        "total": 1099511627776
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!