简体   繁体   English

Microsoft Graph - 搜索 OneDrive

[英]Microsoft Graph - Searching OneDrive

Based on the Microsoft Graph REST API documentation , we have Xamarin/C# code that looks something like this:基于Microsoft Graph REST API 文档,我们的 Xamarin/C# 代码如下所示:

var graphClient = new GraphServiceClient(
   new DelegateAuthenticationProvider(
      (requestMessage) =>
         {
            requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", accessToken);
            return (Task.FromResult(0));
         }
      ));
IDriveItemSearchCollectionPage search = await graphClient.Me.Drive.Root
   .Search("{search-query}")
   .Request()
   .GetAsync();

The problem is, I can't find any documentation about what "{search-query}" can be.问题是,我找不到任何关于“{search-query}”可以是什么的文档。 By trial and error, it appears that:通过反复试验,看来:

  1. Searching for "A" finds all files that contain an "A" in their name or contents搜索“A”会查找名称或内容中包含“A”的所有文件
  2. Searching for "{search-query}" returns a couple of files, I have no idea why搜索“{search-query}”返回几个文件,我不知道为什么
  3. Searching for "filename:A" returns nothing even though I have a few files that contain "A" in their name即使我有一些文件名中包含“A”,搜索“文件名:A”也不会返回任何内容

I want to search for all files whose name contains a certain substring, but if I search for "*" or "filename:A*" or "filename:A%2A" it throws a ServiceException with the code UnknownError.我想搜索名称包含某个 ZE83AED3DDF4667DEC0DAAAACB2BB3BE0BZ 的所有文件,但如果我搜索“*”或“文件名:A*”或“文件名:A%2A”,它会抛出带有代码 UnknownError 的 ServiceException。

Question 1 : How do I pass a wildcard to the Search() function?问题 1 :如何将通配符传递给 Search() function?

Then, when I do get results, it's a Microsoft.Graph.DriveItemSearchCollectionPage , I can enumerate through that and get a bunch of DriveItem objects.然后,当我得到结果时,它是一个Microsoft.Graph.DriveItemSearchCollectionPage ,我可以枚举它并获得一堆DriveItem对象。 DriveItem has a property named "Folder" that is sometimes non-null , but it's an object of type Microsoft.Graph.Folder and Intellisense indicates there is no way to get the name of the folder. DriveItem有一个名为“Folder”的属性,该属性有时为非 null ,但它是Microsoft.Graph.Folder类型的 object 并且 Intellisense 表示无法获取文件夹的名称。 And the current version of Visual Studio Mac is screwy, if I right-click on a folder and select "Go To Declaration" it immediately hangs and uses 100% CPU and never returns, I have to Force Quit.而且当前版本的 Visual Studio Mac 很麻烦,如果我右键单击一个文件夹并 select “转到声明”它会立即挂起并使用 100% CPU 并且永远不会返回,我必须强制退出。

Question 2 : How do I get the name of a folder when I have a Microsoft.Graph.Folder ?问题 2 :当我有Microsoft.Graph.Folder时,如何获取文件夹的名称?

I'm not familiar with the Drive search query syntax.我不熟悉云端硬盘搜索查询语法。

I can say that when the Folder property is non-null, it indicates that the DriveItem is a folder.我可以说当Folder 属性为非null 时,它表明DriveItem 是一个文件夹。 You'll use DriveItem.Name to get the name of the folder.您将使用 DriveItem.Name 来获取文件夹的名称。

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

相关问题 用于OneDrive的Microsoft Graph API响应服务不可用 - Microsoft Graph API for OneDrive responds with service not available Microsoft Graph 列出 OneDrive 项目的最大数量? - Microsoft Graph Maximum number for List OneDrive Items? Microsoft Graph .Net API:共享的OneDrive文件夹 - Microsoft Graph .Net API: Shared OneDrive folder 使用Microsoft图表将文件上传到onedrive以进行业务 - Uploading file to onedrive for business using Microsoft graph Microsoft Graph API-从OneDrive获取最新的照片缩略图 - Microsoft Graph API - Get most recent photo thumbnails from OneDrive Microsoft Graph:将文件从URL [C#]上传到onedrive - Microsoft Graph: upload files to onedrive from URL [C#] 如何在 c# 中使用 Microsoft Graph Api 上传到 OneDrive - How to upload to OneDrive using Microsoft Graph Api in c# 使用 Microsoft graph API 获取 OneDrive 中的所有文件夹 - Fetch all the folders in OneDrive using Microsoft graph API 带有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 无法使用Microsoft Graph以全局管理员身份查询用户的OneDrive业务文件 - Cannot Query Users' OneDrive For Business Files As The Global Administrator using Microsoft Graph
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM