Don't miss your chance to take exam DP-600 or DP-700 on us!
Request nowLearn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
Following numerous tutorials online, I have successfully configured a query in PowerBi to connect to Microsoft Graph and pull down a list of SharePoint Online Sites (and subsites). It uses a Azure app to provide the relevant permissions to get the data, with a shared seceret for authentication.
Here's the advanced query:
let
resource="https://graph.microsoft.com",
tokenResponse = Json.Document(Web.Contents("https://login.windows.net/",
[
RelativePath = #"Tenant ID" & "/oauth2/token",
Content = Text.ToBinary(Uri.BuildQueryString(
[
client_id = #"Azure Application ID",
resource = resource,
grant_type = "client_credentials",
client_secret = #"Azure Application Client Secret"
]
)),
Headers = [Accept = "application/json"], ManualStatusHandling = {400}
])),
access_token = tokenResponse[access_token],
Source = OData.Feed("https://graph.microsoft.com/beta/sites", [ Authorization = "Bearer " & access_token ], [ ExcludedFromCacheKey = {"Authorization"}, ODataVersion = 4, Implementation = "2.0" ]),
#"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type)
in
#"Added Index"Next I want to reduce the amount of data being imported, to speed things up. No point importing all of it and then filtering it, its going to be slow. (Something like 70% of the sites are going to be personal OneDrive sites)
The most obvious filter to start with is ignoring OneDrive sites by checking 'isPersonalSite' = FALSE. No matter syntax I try, it does not work.
Alternatively, looking in the 'id' for only <domainname>.sharepoint.com. ignoring all those that are <domainname>-my.sharepoint.com.
Any suggestions on how to get one of these working with Sites? (Ideally the 'isPersonalSite' one)
Thanks in advanced for ideas and suggestions 🙂
Solved! Go to Solution.
Hi @Blue407
After a bit of Googling and tinkering on my own tenant, the below query seems to work.
The changes I made were:
let
resource = "https://graph.microsoft.com",
tokenResponse = Json.Document(
Web.Contents(
"https://login.windows.net/",
[
RelativePath = #"Tenant ID" & "/oauth2/token",
Content = Text.ToBinary(
Uri.BuildQueryString(
[
client_id = #"Azure Application ID",
resource = resource,
grant_type = "client_credentials",
client_secret = #"Azure Application Client Secret"
]
)
),
Headers = [Accept = "application/json"],
ManualStatusHandling = {400}
]
)
),
access_token = tokenResponse[access_token],
Source = OData.Feed(
"https://graph.microsoft.com/beta/sites/getAllSites",
[Authorization = "Bearer " & access_token],
[
ExcludedFromCacheKey = {"Authorization"},
ODataVersion = 4,
Implementation = "2.0",
Query = [filter = "isPersonalSite eq false"]
]
),
#"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type)
in
#"Added Index"
Notes:
Does this work for you?
Hi @Blue407
After a bit of Googling and tinkering on my own tenant, the below query seems to work.
The changes I made were:
let
resource = "https://graph.microsoft.com",
tokenResponse = Json.Document(
Web.Contents(
"https://login.windows.net/",
[
RelativePath = #"Tenant ID" & "/oauth2/token",
Content = Text.ToBinary(
Uri.BuildQueryString(
[
client_id = #"Azure Application ID",
resource = resource,
grant_type = "client_credentials",
client_secret = #"Azure Application Client Secret"
]
)
),
Headers = [Accept = "application/json"],
ManualStatusHandling = {400}
]
)
),
access_token = tokenResponse[access_token],
Source = OData.Feed(
"https://graph.microsoft.com/beta/sites/getAllSites",
[Authorization = "Bearer " & access_token],
[
ExcludedFromCacheKey = {"Authorization"},
ODataVersion = 4,
Implementation = "2.0",
Query = [filter = "isPersonalSite eq false"]
]
),
#"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type)
in
#"Added Index"
Notes:
Does this work for you?
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 10 | |
| 9 | |
| 7 | |
| 5 | |
| 5 |