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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

Forbidden error on fetching dataset parameters

Please forgive me if I ask stupid quesions as I'm new to everything.

Essentially I'd like to copy a Power BI report from one workspace to another and then modify the data source's parameters. The datasource is backed by Databricks.

I've followed this article https://docs.microsoft.com/en-us/power-bi/developer/embedded/embed-service-principal to set up a service principle, then generated a secret so that I could authenticate with the Power BI API.

I then assigned the service principal as an Admin of the Power BI workspaces.

I was able to run the code snippet below to authenticate

 

$azureAplicationId = "<redacted>"
$azureTenantId = "<redacted>"
$servicePrincipalSecret = ConvertTo-SecureString "<redacted>" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($azureAplicationId , $servicePrincipalSecret)
Connect-PowerBIServiceAccount -ServicePrincipal -Credential $psCred -Tenant $azureTenantId

 

Then I was able to download a report from one workspace and copy it to another:

 

Export-PowerBIReport -Id $report.Id -WorkspaceId $ws.Id -OutFile "$($reportName).pbix"
New-PowerBIReport -Path "$($reportName).pbix" -WorkspaceId $targetWs.Id -Timeout 3600 -Name "$($reportName)._"

 

 However, I got the 403 error when I tried to fetch information of the dataset associated with a workspace

 

$dataset = Get-PowerBIDataset -Id $report.DatasetId -WorkspaceId $ws.Id
Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/datasets/$($dataset.Id)/parameters" -Method Get
Invoke-PowerBIRestMethod: One or more errors occurred. (Response status code does not indicate success: 403 (Forbidden).)

 

A little bit more detailed of the error:

 

PS /home/ubuntu> Resolve-PowerBIError -Last

   HistoryId: 63

Message        : Response status code does not indicate success: 403 (Forbidden).
StackTrace     :    at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
                    at Microsoft.PowerBI.Commands.Profile.InvokePowerBIRestMethod.InvokeRestMethod(String url, String body, PowerBIWebRequestMethod requestType)
Exception      : System.Net.Http.HttpRequestException
InvocationInfo : {Invoke-PowerBIRestMethod}
Line           : Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/datasets/$($dataset.Id)/parameters" -Method Get
Position       : At line:1 char:1
                 + Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/dat …
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 63

 

I'm not really sure what I've done wrong. Any help would be highly appreciated.

Thanks.

3 REPLIES 3
DemiHaung
Frequent Visitor

Hi @Anonymous 

 

how di you address the issue, cause right now im also experiencing the same issue.

 

Thanks

v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

Did you check the considerations and limitations at the end of the article?

 

Here are some tips to try on the device:

1.Check the Requested URL
2.Clear Relevant Cookies
3.Clear the Cache
4.Log Out and Log In
5.Debugging Common Platforms
6.Rollback Recent Upgrades
7.Uninstall New Extensions, Modules, or Plugins
8.Check for Unexpected Database Changes
9.Confirm Proper File Permissions

 

 

Best Regards,

Stephen Tao

 

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

Anonymous
Not applicable

Anyone?

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors