C# 使用Microsoft Graph API DriveItems搜索时,仅显示sharepoint中的几个文件名
我正在使用以下代码在sharepoint中搜索文件:C# 使用Microsoft Graph API DriveItems搜索时,仅显示sharepoint中的几个文件名,c#,sharepoint,microsoft-graph-api,C#,Sharepoint,Microsoft Graph Api,我正在使用以下代码在sharepoint中搜索文件: string cSecret = "XXXXXX"; string cId = "XXXXXXX"; var scopes = new string[] { "https://graph.microsoft.com/.default" }; var confidentialClient = ConfidentialClientApplicationBuilder .Create(cId) .WithAuthority($"ht
string cSecret = "XXXXXX";
string cId = "XXXXXXX";
var scopes = new string[] { "https://graph.microsoft.com/.default" };
var confidentialClient = ConfidentialClientApplicationBuilder
.Create(cId)
.WithAuthority($"https://login.microsoftonline.com/XXXXX.onmicrosoft.com/v2.0")
.WithClientSecret(cSecret)
.Build();
string requestUrl;
GraphServiceClient graphClient =
new GraphServiceClient(new DelegateAuthenticationProvider(async (requestMessage) =>
{
var authResult = await confidentialClient
.AcquireTokenForClient(scopes)
.ExecuteAsync();
// Add the access token in the Authorization header of the API request.
requestMessage.Headers.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", authResult.AccessToken);
}));
requestUrl = "https://graph.microsoft.com/beta/search/query";
var files = await graphClient.Drive.Root
.Search("policy")
.Request()
.GetAsync();
do
{
foreach (DriveItem file in files)
{
Console.WriteLine(file.Name);
}
} while (files.NextPageRequest != null && (files = await files.NextPageRequest.GetAsync()).Count > 0);
但是,文件中只显示一个文件名。名称和页数为空,下一页为空。
我手动检查并使用下面的api
https://XXXX.sharepoint.com/_api/search/query?querytext='policy'
在sharepoint中,我搜索策略时会有很多结果
请帮助我获得使用上述代码的所有文件