SOLVED

How do I search across all sites using Microsoft Graph?

Brass Contributor

I want to develop an application that displays a search result. For testing I uploaded a couple of files to the default document library in the root site. I can see these files with the following request:

https://graph.microsoft.com/v1.0/sites/root/drive/root/search(q='Test')

However, one of the requirements is that the query should match files regardless of in which site they are stored. As I understand the documentation I should use something like this:

https://graph.microsoft.com/v1.0/me/drive/search(q='Test')

The query is the same as in the first example but the results are empty.

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(driveItem)",
    "value": []
}
1 Reply
best response confirmed by Gabriel Smoljar (Brass Contributor)
Solution

It sounds to me like what you're looking for isn't the Graph API, but the Search API.

 

https://docs.microsoft.com/en-us/sharepoint/dev/general-development/sharepoint-search-rest-api-overv...

1 best response

Accepted Solutions
best response confirmed by Gabriel Smoljar (Brass Contributor)