简体   繁体   English

带有Service / Daemon应用程序的Microsoft Graph CSharp SDK和OneDrive for Business - Quota facet返回null

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

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. 我正在针对OneDrive for Business Microsoft Graph CSharp SDK进行编码,我正在尝试撤回特定User数据并请求返回Quota信息。

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 . 问题 - 返回的数据全为null Does the Microsoft Graph SDK have support to pull back Quota facet for OneDrive for Bussiness accounts? Microsoft Graph SDK是否支持撤回OneDrive for Bussiness帐户的Quota方面?

Update 更新

I am also providing the client_id , client_secret , and tenant_name to authenticate on an application-level permission. 我还提供了client_idclient_secrettenant_name来对应用程序级权限进行身份验证。

Update 更新

Added a screenshot for drive since it returns all null. 添加了drive的屏幕截图,因为它返回所有null。

在此输入图像描述

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. 如果您在令牌中有Files.Read.All或Files.ReadWrite.All作用域,则App Only调用确实没有返回配额和所有者信息。 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. 但是,作为一种解决方法,您可以为您的应用使用Sites.FullControl.All范围,并且应该返回配额和所有者信息。

The quota.used facet is not being returned by the service (I'll report this issue). 该服务未返回quota.used facet(我将报告此问题)。 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. 更新要回答原始问题...是,Microsoft Graph .Net客户端库确实支持OneDrive for Business帐户上的配额和用户。

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? 我不熟悉OneDrive for Business配额......你可能没有配额吗? 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. 我成功找回了没有used属性的配额对象。 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
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用OneDrive CSharp SDK作为服务或守护程序应用程序? - How to use OneDrive CSharp SDK as a Service or daemon app? 使用Microsoft图表将文件上传到onedrive以进行业务 - Uploading file to onedrive for business using Microsoft graph 使用Windows窗体应用程序获取OneDrive for Business的配额 - Get OneDrive for Business use's quota using windows form application 用于OneDrive的Microsoft Graph API响应服务不可用 - Microsoft Graph API for OneDrive responds with service not available Microsoft Graph CSharp SDK和过滤-如何构造对CreatedDateItem进行过滤的调用? - Microsoft Graph CSharp SDK and filtering - how to construct a call to filter on CreatedDateItem? Microsoft Graph - 搜索 OneDrive - Microsoft Graph - Searching OneDrive 无法使用Microsoft Graph以全局管理员身份查询用户的OneDrive业务文件 - Cannot Query Users' OneDrive For Business Files As The Global Administrator using Microsoft Graph OneDrive for Business的Microsoft Graph API是否可以过滤文件扩展名? - Does Microsoft Graph API for OneDrive for Business have the ability to filter on file extensions yet? Microsoft Graph CSharp SDK和筛选-如何构造在两个不同日期进行筛选的请求? - Microsoft Graph CSharp SDK and Filtering - How to construct a request to filter on two different dates? Authorization_IdentityNotFound 从守护程序应用程序访问 Microsoft Graph - Authorization_IdentityNotFound accessing Microsoft Graph from daemon application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM