How to get all SharePoint sites of organization using Microsoft Graph API?

Casepoint Developer 66 Reputation points
2022-11-24T10:02:25.697+00:00

Hello Team,

We are an eDiscovery Company and we want to build the same functionality as Microsoft eDiscovery (Purview) for Preservation of SharePoint sites.

We are using following API to preserve SharePoint site:
API : POST /compliance/ediscovery/cases/{caseId}/legalHolds/{legalholdId}/siteSources
document link : https://learn.microsoft.com/en-us/graph/api/ediscovery-legalhold-post-sitesources?view=graph-rest-beta&tabs=http

Here we need to pass SharePoint site URL in above API to preserve data of that site.

We want to provide SharePoint site selection option to the user and for that we want to know from which API we get a list of all sites of the organization?

Thanks & Regards

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. CarlZhao-MSFT 46,376 Reputation points
    2022-11-28T03:13:06.507+00:00

    Hi @Casepoint Developer

    Of course, you can use the search=* query parameter to list all sites in your organization. This method supports the Sites.Read.All delegated permission.

    https://graph.microsoft.com/v1.0/sites?search=*  
    

    264564-image.png


    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.

    2 people found this answer helpful.

  2. Vasil Michev 119.7K Reputation points MVP Volunteer Moderator
    2022-11-24T10:27:18.68+00:00

    You can use the /sites endpoint:

    GET https://graph.microsoft.com/v1.0/sites  
    

    However, it will only work with APPLICATION permissions, not delegate ones. Refer to the official documentation for more info: https://learn.microsoft.com/en-us/graph/api/site-list?view=graph-rest-1.0


  3. CarlZhao-MSFT 46,376 Reputation points
    2022-11-24T10:28:12.39+00:00

    Hi @Casepoint Developer

    You can call the list sites api endpoint to list all available sites in your organization. Also, note that only application permissions are supported for listing all site collections.

    263818-image.png

    263893-image.png


    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.