Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Alex_Roughag
Regular Visitor

Getting SharePoint activity report into Power Bi

Hello,

I'm trying to load a SharePoint Site Usage Detail (https://graph.microsoft.com/v1.0/reports/getSharePointSiteUsageDetail(period='D180')) report with OData feed into Power Bi, but I'm getting an error "Access to the resource is forbidden", even though I can easily download https://graph.microsoft.com/V1.0/groups data.

I use a Global Administrator and I tried to add SharePoint Administrator and Reports Reader roles, but the error remains.

Is there any way I can get that report or is there a workaround?

Thank you.

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Alex_Roughag ,

 

Have a good day. I made a sample for you.

1\ Registe app in Entra ID and get client id, token link.

vxiaocliumsft_0-1722577029697.png

vxiaocliumsft_1-1722577035204.png

2\ Set permission

vxiaocliumsft_2-1722577099811.png

vxiaocliumsft_3-1722577111144.png

vxiaocliumsft_4-1722577125989.png

3\ Add secret and copy it

vxiaocliumsft_5-1722577147659.png

4\ Create a blank query in BI desktop

vxiaocliumsft_6-1722577159014.png

 

let

    //POST Request
    url = "<token link>",
    body = [
        scope = https://graph.microsoft.com/.default,
        client_id = "<client id>",
        client_secret="<secret value>",
        grant_type = "client_credentials"
    ],


     GetJson =
        Json.Document(
            Web.Contents(
                url, [
                    Headers=[
                        Accept="application/json", 
                        #"Content-Type"="application/x-www-form-urlencoded"
                    ], 
                    Content= Text.ToBinary(Uri.BuildQueryString(body))
                ]
            )
        ),
    access_token = GetJson[access_token],
    url2= https://graph.microsoft.com/v1.0,
    Result= Csv.Document(Web.Contents(url2, [RelativePath="/reports/getSharePointSiteUsageDetail(period='D180')", Headers=[Accept="*/*", authorization="Bearer "&access_token]]),[Delimiter=",", Columns=15, Encoding=65001, QuoteStyle=QuoteStyle.None]),
    #"Promoted Headers" = Table.PromoteHeaders(Result, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Report Refresh Date", type date}, {"Site Id", type text}, {"Site URL", type text}, {"Owner Display Name", type text}, {"Is Deleted", type logical}, {"Last Activity Date", type date}, {"File Count", Int64.Type}, {"Active File Count", Int64.Type}, {"Page View Count", Int64.Type}, {"Visited Page Count", Int64.Type}, {"Storage Used (Byte)", Int64.Type}, {"Storage Allocated (Byte)", Int64.Type}, {"Root Web Template", type text}, {"Owner Principal Name", type text}, {"Report Period", Int64.Type}})
in
    #"Changed Type"

 

5 Upload to service and set certification.

vxiaocliumsft_7-1722577189670.png

 

vxiaocliumsft_8-1722577196485.png

 

Best Regards,

Wearsky

View solution in original post

2 REPLIES 2
Alex_Roughag
Regular Visitor

Thank you @Anonymous that works.

The only correction is that URL needs to be in quotes in order the query to work.

Anonymous
Not applicable

Hi @Alex_Roughag ,

 

Have a good day. I made a sample for you.

1\ Registe app in Entra ID and get client id, token link.

vxiaocliumsft_0-1722577029697.png

vxiaocliumsft_1-1722577035204.png

2\ Set permission

vxiaocliumsft_2-1722577099811.png

vxiaocliumsft_3-1722577111144.png

vxiaocliumsft_4-1722577125989.png

3\ Add secret and copy it

vxiaocliumsft_5-1722577147659.png

4\ Create a blank query in BI desktop

vxiaocliumsft_6-1722577159014.png

 

let

    //POST Request
    url = "<token link>",
    body = [
        scope = https://graph.microsoft.com/.default,
        client_id = "<client id>",
        client_secret="<secret value>",
        grant_type = "client_credentials"
    ],


     GetJson =
        Json.Document(
            Web.Contents(
                url, [
                    Headers=[
                        Accept="application/json", 
                        #"Content-Type"="application/x-www-form-urlencoded"
                    ], 
                    Content= Text.ToBinary(Uri.BuildQueryString(body))
                ]
            )
        ),
    access_token = GetJson[access_token],
    url2= https://graph.microsoft.com/v1.0,
    Result= Csv.Document(Web.Contents(url2, [RelativePath="/reports/getSharePointSiteUsageDetail(period='D180')", Headers=[Accept="*/*", authorization="Bearer "&access_token]]),[Delimiter=",", Columns=15, Encoding=65001, QuoteStyle=QuoteStyle.None]),
    #"Promoted Headers" = Table.PromoteHeaders(Result, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Report Refresh Date", type date}, {"Site Id", type text}, {"Site URL", type text}, {"Owner Display Name", type text}, {"Is Deleted", type logical}, {"Last Activity Date", type date}, {"File Count", Int64.Type}, {"Active File Count", Int64.Type}, {"Page View Count", Int64.Type}, {"Visited Page Count", Int64.Type}, {"Storage Used (Byte)", Int64.Type}, {"Storage Allocated (Byte)", Int64.Type}, {"Root Web Template", type text}, {"Owner Principal Name", type text}, {"Report Period", Int64.Type}})
in
    #"Changed Type"

 

5 Upload to service and set certification.

vxiaocliumsft_7-1722577189670.png

 

vxiaocliumsft_8-1722577196485.png

 

Best Regards,

Wearsky

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.