本文介绍了用户?$ expand =驱动器失败,并显示InternalServerError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们希望能够在集合中包括有关每个用户的个人站点(OneDrive for Business)的信息,以避免随后对Microsoft Graph的请求效率低下.

We want to be able to include the information about each individual user's personal site (OneDrive for Business) within a collection, to avoid inefficient subsequent requests to Microsoft Graph.

通过/users?$select=id,mail,mySite获取用户集合时,Microsoft Graph API不允许查询mySite字段. 图形API文档.因此,我们正在寻找替代方案,并遇到了:

Microsoft Graph API doesn't allow to query for the mySite field when getting a user collection via /users?$select=id,mail,mySite. This fact is documented in the Graph API docs. Thus we were looking for an alternative, and came across:

GET /users?$expand=drive

GET /users?$expand=drives

因为drive对应于用户的个人驱动器,并且具有与mySite相同的字段webUrl.

because drive corresponds to the user's personal drive and has the field webUrl which is the same as mySite.

但是请求导致以下错误:

But the requests result in the following error:

{
    "error": {
        "code": "InternalServerError",
        "message": "Value cannot be null. Parameter name: source",
        "innerError": {
            "request-id": "15d69169-937a-4525-a904-e4107704d8f1",
            "date": "2017-11-08T02:11:17"
        }
    }
}

这是有效的书面关系.同样,也没有文件证明不支持使用$expand查询参数.尽管在此处上有一条注释,写着beta/users支持>,但这仍然会失败,并显示相同的错误.

This is a valid documented relationship. Also nowhere is it documented that this use of the $expand query parameter is not supported. Though there is a note here that says $expand is for now only supported by the beta/users, but this still fails with the same error.

该错误的潜在原因可能是用户尚未创建个人站点,因此我们尝试drives(如上所述),假设它可能仅返回一个空列表,并且还会返回以下内容:

A potential cause of the error could be that the user hasn't created a personal site yet, thus we tried drives (as stated above) assuming it might just return an empty list and also the following:

GET /users?$expand=drive&$filter=drive ne null

但是这也会返回错误,指出Filter is not supported.尽管不能使用$filter,但没有记录. (如果我们正确理解的话).

But this also returns an error, stating that Filter is not supported. Though that $filter can't be used like that is not documented. Only that $expand=drive($select=webUrl;$filter=webUrl ne null) is not supported as documented here (if we understand that correctly).

我们搜索了办公功能建议平台,Stack Overflow和Microsoft的技术社区开发人员小组,但没有成功.

We searched the office feature suggestion platform, Stack Overflow, and the Microsoft's tech community developer group, without success.

仍然存在发现API,但这并不是真正的选择,因为我们使用仅应用程序令牌.此外,如.

There is still the discovery API but this is not really an option because we use an app-only token. Furthermore does it look like that Microsoft Graph is also supposed to replace it, as mentioned here.

推荐答案

user实体扩展drive.至于原因,我将尝试解释.

Expanding a drive from a user entity isn't supported by Microsoft Graph. As to why, I will attempt to explain.

要了解此行为,将其导入以考虑给定实体的来源.在这种情况下,user来自Active Directory,而drive来自SharePoint.

To understand this behavior, it's imported to consider where a given entity is sourced from. In this case the user comes from Active Directory while the drive is sources from SharePoint.

文档中所述:

仅使用示例,请注意directReportsmanagermemberOf都来自AD,而eventsmessagesphoto都来自Exchange.

Using just the example, notices that directReports, manager, and memberOf are all sourced from AD while events, messages, or photo are all source from Exchange.

文档试图解释的内容(尽管以一种相当混乱和绕过的方式)是$expand不能跨越服务边界.如果关系从一项服务转移到另一项服务(即Exchange和SharePoint),则Microsoft Graph无法在单个调用中跨越该边界.

What the documentation is attempting to explain (albeit in a rather confusing and round-about way) is that $expand can't cross service boundaries. If the relationship crosses from one service to another (i.e. Exchange and SharePoint), Microsoft Graph isn't able to navigate across that boundary in a single call.

部分原因是通过Microsoft Graph呈现的具有不同规则和约束的各种服务.例如,Exchange在节流方面与OneNote有不同的规则.在解决要应用的规则时,通过$expand在服务之间进行交叉会带来问题.

Part of this stems from the various services surfaced through Microsoft Graph having different rules and constraints. For example, Exchange has different rules around throttling than OneNote. Crossing between services via $expand would present problems when it comes to resolving which rules to apply.

希望这会有所帮助.

这篇关于用户?$ expand =驱动器失败,并显示InternalServerError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 17:45