Microsoft Graph CSharp SDK and OneDrive for Busine

2019-06-04 18:02发布

I am coding against Microsoft Graph CSharp SDK for OneDrive for Business and I am trying to pull back data on a specific User and request back Quota information.

My request:

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

The problem - the data that is returned is all null. Does the Microsoft Graph SDK have support to pull back Quota facet for OneDrive for Bussiness accounts?

Update

I am also providing the client_id, client_secret, and tenant_nameto authenticate on an application-level permission.

Update

Added a screenshot for drive since it returns all null.

enter image description here

2条回答
手持菜刀,她持情操
2楼-- · 2019-06-04 18:35

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
    }
}
查看更多
贼婆χ
3楼-- · 2019-06-04 18:47

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.

查看更多
登录 后发表回答