Showing results for 
Search instead for 
Did you mean: 
Regular Visitor

Rdl import via API 400 Bad Request



I have an application where you can upload .pbix and .rdl reports to PowerBI.


I can successfully import .pbix reports via API. Hovewer, when I run import for .rdl file on the API, I am getting an error - 400 Bad Request RequestedFileIsEncryptedOrCorrupted.


PowerBI setup is proper and I have a premium account, the token is proper as well.



string importURL = string.Format("{0}/groups/{1}/imports?datasetDisplayName={2}&nameConflict=Overwrite", PowerBiServiceRootUrl, GroupId, datasetDisplayName);

var importResponse = ImportPBI(FileName, importURL);

public string ImportPBI(string pbiFilePath, string url)
            // create REST URL with import name in quer string
            string restUrlImportPbi = url;

            // load PBI file into StreamContent object
            var pbiBodyContent = new StreamContent(File.Open(pbiFilePath, FileMode.Open));

            // add headers for request bod content
            pbiBodyContent.Headers.Add("Content-Type", "application/octet-stream");
                                         @"form-data; name=""file""; filename=""" + pbiFilePath + @"""");

            // load PBI content into body using multi-part form datas
            MultipartFormDataContent requestBody = new MultipartFormDataContent(Guid.NewGuid().ToString());

            // create and configure HttpClient
            HttpClient client = new HttpClient();
            client.DefaultRequestHeaders.Add("Accept", "application/json");
            client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);

            // post request
            var response = client.PostAsync(restUrlImportPbi, requestBody).Result;

            // check for success
            return response.StatusCode.ToString();




Thank you and looking forward to hearing back from you.


Helpful resources

May 2020 Community Highlights

May 2020 Community Highlights

It’s time for another PBI Community recap!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.



Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!