Search code examples
sharepointgraphmicrosoft-graph-api

How can I see all the SharePoint Sites a user is an owner of with Microsoft Graph?


I'm trying to get as a response preview on Microsoft Graph all the SharePoint sites a user is a part of, using a "get" querie but haven't got anywhere

I've tried with my user and other users, with their ID, name, username and email, the best result I got was with the ID but it wasn't even close of what I needed. This is the code that most helped me so far:

https://graph.microsoft.com/v1.0/sites/microsoft.graph.getAllSites()

And I was trying to find a way to insert into the parentesis a way to identify the user, but I'm starting to think this is not what that parameter is for.

So all I need is to just get, through an user ID, name, username or anything that'd identify the user, all the SharePoint Sites this user is an owner of.


Solution

  • To see all the SharePoint sites a user is an owner of with Microsoft Graph, you can use the following query:

    GET https://graph.microsoft.com/v1.0/sites?search=owners:{userPrincipalName}