[英]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:通过反复试验,看来:
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.