An API that connects multiple Microsoft services, enabling data access and automation across platforms
Search Files with Graph SDK
Hello, I would like to search for a file with the Graph SDK(ASP.Net Core and C#), with Postman this also works as desired.
https://graph.microsoft.com/v1.0/users/{user-id}/drive/root/search(q='Filename')
But I just can't get it to work with the SDK (empty collection).
private async Task<IDriveItemSearchCollectionPage> SearchFiles(GraphServiceClient graphClient){
var search = await graphClient.Users["User-iD"].Drive.Root
.Search("Filename")
.Request()
.GetAsync();
return search;
}
And the associated iterator:
private void PrintFiles(IDriveItemSearchCollectionPage files) {
foreach(var file in files) {
var message = $"File: {file.Name}, Id: {file.Id}";
Console.WriteLine(message);
}
}
What am I doing wrong ?
I would be very happy to receive help.
Greetings
Microsoft Security | Microsoft Graph
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
Developer technologies | ASP.NET Core | Other
A set of technologies in .NET for building web applications and web services. Miscellaneous topics that do not fit into specific categories.
1 answer
Sort by: Most helpful
-
Deleted
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
2 deleted comments
Comments have been turned off. Learn more