Graph API /Site?Search={query} not returning One Drive For Business sites

Casepoint Developer 66 Reputation points
2023-02-23T13:39:05.64+00:00

Hi There,

We are eDiscovery company and wanting to provide functionality where Admin user can get all the share point sites of the specified custodian.

We have a large number of sites available in an organization

Calling the /sites API would not help as we have to page and get all the sites to search for a specific site.

We came across**/Sites?Search={query}** API documentation which resolved our concerns about searching the sites.

To make sure we used /Site?Search=* to fetch all the sites and to our surprise, we are not getting One Drive For Business sites in the searching API, however we are getting those in /sites.

We even tried using the keywords /Site?Search=test for One Drive For Business site however we are still not able to get the One Drive For Business sites.

Please help us further on this as we want to only use /Sites?Search={query}  API using application permission to search all the sites in an organization.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,716 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,743 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 31,681 Reputation points Microsoft Vendor
    2023-02-24T08:16:28.1933333+00:00

    Hi @Casepoint Developer

    Per my test, I am able to get ondrive site by GET https://graph.microsoft.com/v1.0/sites. You can refer to the following document

    https://learn.microsoft.com/en-us/graph/api/site-list?view=graph-rest-1.0

    In my case, I am unable to retrieve One Drive For Business sites by GET https://graph.microsoft.com/v1.0/sites?search={query}.

    The api only returns the collection of drives (document libraries) under this site. You can refer to the following document

    https://learn.microsoft.com/en-us/graph/api/site-search?view=graph-rest-1.0&tabs=http

    https://learn.microsoft.com/en-us/graph/api/resources/site?view=graph-rest-1.0#relationships


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.