Forum Discussion

Gulfam's avatar
Gulfam
New Member
4 years ago
Solved

Error 403: Access to api.powerbi.com was denied

When I try to get report using end point provided in documentation. I get Error 403 "Access to api.powerbi.com was denied". The Url I am using to access report is https://api.powerbi.com/v1.0/myorg...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi  Gulfam ,

     

    Do you want to connect to Power BI REST API in Power BI Desktop and you will get 403 errror?

    Firstly, we need to get Access token in Power BI Desktop. We will get access token from Power BI by below code.

    Please replace the parameters like "client_id","APP ID" and so on by correct values.

    () =>
    
     
    
    let
    
        body = "client_id=" & #"App ID"
    
        & "&scope=https://analysis.windows.net/powerbi/api/.default&client_secret=" & #"App Secret"
    
        & "&grant_type=client_credentials",
    
        Data= Json.Document(Web.Contents("https://login.microsoftonline.com/"& TenantID & "/oauth2/v2.0/token/",
    
        [Headers=[#"Content-Type"="application/x-www-form-urlencoded"], Content=Text.ToBinary(body)])),
    
        access_token = Data[access_token]
    
    in
    
        access_token

    OR

    () =>
    
     
    
    let
    
        body =  "&grant_type=Password&resource = https://analysis.windows.net/powerbi/api
    
    &client_id=*****&username=*****&password=*****",
    
        
     Data=Json.Document(Web.Contents("https://login.microsoftonline.com/common/oauth2/v2.0/token/",
    
        [Headers=[#"Content-Type"="application/x-www-form-urlencoded"], Content=Text.ToBinary(body)])),
    
        access_token = Data[access_token]
    
    in
    
        access_token

    Then you can follow this video to get data from the Rest API by access token in first step. 

     

    Finally, you can replace bear token by the access token parameter. 

     

    It will refresh every time your refresh your report.

    Video: How to get access token and call Rest API by dynamic access token in Power BI Desktop? (5:30 to 9:30)

    all Power BI Rest API with Dynamic Access Token From Power BI Desktop |Power BI Rest API 

     

    For more details, you may refer to this offical blog to learn more details about Get Report Rest API. 

     

    Best Regards,
    Rico Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.