Power BI REST API

khouloud Belhaj 91 Reputation points
2021-07-09T13:27:31.817+00:00

Hi , I'm trying to get all the datasources for my organization.I'm using a service principal to connect to Power BI Service.
I made a function with PowerShell where I have made a this loop to get all the datasetId.


$OrgWorkspaces = Get-PowerBIDataset -Scope Organization
foreach ( $OrgWorkspace in $OrgWorkspaces)
{
$DatasetId= $($OrgWorkspace.Id)

Write-Host $DatasetId

}


And this worked But when I added this line of code
** $DataSources = Get-PowerBIDatasource -DatasetId $DatasetId*******
into the loop It didn't work ! I tried to put a DatasetId from the list I had
****** $DataSources = Get-PowerBIDatasource -DatasetId 1505150a-36f2-408e-a1e7-3531e6e0fccf ******** but I have this error:
[Error] ERROR: Operation returned an invalid status code 'Forbidden'Exception :Type : Microsoft.Rest.HttpOperationExceptionRequest :Method : GETRequestUri : https://api.powerbi.com/v1.0/myorg/datasets/1505150a-36f2-408e-a1e7-3531e6e0fccf/datasourcesHeaders :Authorization : …User-Agent : MicrosoftPowerBIMgmt/1.2.0.0Response :StatusCode : ForbiddenReasonPhrase : ForbiddenContent : {"Message":"API is not accessible for application".

Any idea of this error please?

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
35,940 questions
0 comments No comments
{count} votes

Accepted answer
  1. Leon Laude 85,651 Reputation points
    2021-07-09T13:31:22.793+00:00

    Hi @khouloud Belhaj ,

    Please note that Power BI is currently not supported in the Q&A forums, the supported products are listed over here https://learn.microsoft.com/en-us/answers/products.

    You may ask the experts in the dedicated Power BI forum over here:
    https://community.powerbi.com/t5/Forums/ct-p/PBI_Comm_Forums

    ----------

    If the reply was helpful please don't forget to upvote and/or accept as answer, thank you!

    Best regards,
    Leon


0 additional answers

Sort by: Most helpful