How do I get content (text) from a searched file using the Microsoft Graph API?

  Kiến thức lập trình

Firstly, I using sdk 4.x version.

I want to create search function from onedrive with graph api.

In the Teams(app) search function case, when I use search function, the apps return info with file’s contents and show stress searching keyword.

I want to show that file’s contents(Not full text, only including search keyword)

But, the search response are’t including content.

So, How can I replace this function? Or Do I wrong use this api?

That is a my search request code.

 var searchResults = await graphServiceClient
     .Drives[driveId2]
     .Root
     .Search(searchQuery)
     .Request()
     .GetAsync();

In graph explorer case(Http request)

https://graph.microsoft.com/v1.0/me/drives/b!SoVLl_cMV0m-LhNDYBjj_A-mBCIl-3dEoicDMVnEfVABgoGg2gexQ7frRHmqg2GK/root/search(q='')

And also, content request case to reponse including ReadTimeout and WriteTimeout


var searchResults = await graphServiceClient
        .Drives[driveId]
        .Items[fileId]
        .Content
        .Request()                   
        .GetAsync();

New contributor

손동진 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT