DEV Community

Upload RDL file(s) to Power BI via API

Kenichiro Nakamura on February 07, 2020

Today, my good friend asked me how to upload RDL file(s) to Power BI. And my answer was "What? Power BI supports RDL now???" :) At the end, this i...
Collapse
 
kenakamu profile image
Kenichiro Nakamura

Interesting... I just run the script again and it simply works in my environment so it could be some setup difference? If you signup for new trial, does it work? Anyway I recommend you to create support ticket to see if support team give some idea.

Collapse
 
mappie profile image
mappie

Actually I don't need a trial, as I am uploading my RLD report for the embed scenario (aka "embedding Power BI content into an application for your customers"). So, the REST API client is authorized through a service principal ID and secret. My code works fine for PBIX files, while it does not for RDL ones. Perhaps there is some issue when the token refers to a service principal, not a user.

Thanks for your feedback!

Collapse
 
craig_leach_f2337b06c9622 profile image
Craig Leach

Thanks for posting this code. I was able to get my Paginated report distribution script working using your code as a base.

Collapse
 
ravadiveeresh profile image
Veeresh Ravadi

This is a great script but my report was empty after uploading then I found out that content type was wrong then I made this change to script

Changed this line: (13)
$fileBody = Get-Content -Path $RdlFilePath -Encoding UTF8

to this
$fileBytes = [System.IO.File]::ReadAllBytes($RdlFilePath)
$encoding = [System.Text.Encoding]::GetEncoding("iso-8859-1")
$filebody = $encoding.GetString($fileBytes)

then my reports were loading fine

Collapse
 
kenakamu profile image
Kenichiro Nakamura

Thanks for the update!

Collapse
 
q00n profile image
q0-0n

Excellent example. I used your post to develop a solution to upload Paginated Reports with a live connection to Azure Analysis Services. Thank you!

One thing that is not clear from the API documentation is how to change the reports name. How would you go about that?

Collapse
 
kenakamu profile image
Kenichiro Nakamura

I also try to figure it out but I couldn't. Maybe we need to re-create it with different name?

Collapse
 
mappie profile image
mappie

Helllo Kenichiro,

can you please confirm that this example does actually work? I have been working on import an RDL report into the Power BI service by means of the REST API for a few days now, but I have not managed to upload the report so far. Although I am coding in Go with direct HTTP request, I have tried also your example as well as a C# one, so that I could find a working solution and then compare the flow with mine in Go.

Typically the error "400 Bad Request RequestedFileIsEncryptedOrCorrupted" is returned.

I also noticed that a plenty of people have faced the same issue, just a few topics found on the Power BI forum confirming that:

Therefore, if you can provide further details on your approach, it would be appreciated.

Best reagrds,
Michał