Microsoft Graph:在 SharePoint 驱动器上搜索 DriveItems 不返回任何结果器上、结果、Graph、Microsoft

2023-09-06 17:57:49 作者:·与你相见·

我在 SharePoint 驱动器中有文件并且想要开发全文搜索.Graph Explorer 中的以下调用有效,通过文件名或内容查找我的文件:

I have files in a SharePoint Drive and want to develop a full-text search. The following call in the Graph Explorer works, finding my files either by filename or content:

https://graph.microsoft.com/v1.0/drives/{my drive id}/root/search(q='my search word')

使用 Microsoft.Graph-NuGet 包从我的 Azure 托管 ASP.NET 应用程序进行的相同调用总是返回一个空列表:

The same call from my Azure hosted ASP.NET app using the Microsoft.Graph-NuGet package allways returns an empty list:

await _client
  .Drives[{my drive id}]
  .Root
  .Search({my search word})
  .Request()
  .GetAsync()

_client 是经过身份验证的 GraphServiceClient.对于身份验证,我通过 Azure AD 端点(在 Azure 门户中注册的应用程序)而不是从 v2 端点(在应用程序注册门户中注册的应用程序)接收令牌.为了排除这个原因,我使用了 v2 Endpoint,但没有区别.

_client is an authenticated GraphServiceClient. For authentication, I receive a token through the Azure AD endpoint (app registered in the Azure Portal), not from the v2 Endpoint (app registered in the Application Registration Portal). To exclude this as a reason, I used the v2 Endpoint but there was no difference.

应用程序具有 Files.ReadWrite.All 权限范围.接收、保存和删除文件工作正常.只有搜索失败.

The application has the Files.ReadWrite.All permission scope. Receiving, saving and deleting files works fine. Only searching fails.

作为测试,我为我的应用程序授予了 Graph Explorer 的所有权利,没有任何区别.我比较了 GraphServiceClient 准备的 URL,但一切看起来都很好.

As a test, I gave my application all rights Graph Explorer has with no difference. I compared the URL the GraphServiceClient prepared but everything looked fine.

推荐答案

这个问题 两天后描述了同样的问题.作者在评论中说,它昨天开始工作,他没有改变任何东西.我今天使用相同的旧代码对其进行了测试.我能说什么?现在可以了!看起来这是微软方面的一个错误?

This question described the same problem two days later. In a comment the author stated, it started working yesterday without him changing anything. I tested it today with my same old Code. What can I say? It works now! Looks like it was a bug on Microsofts side?