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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
luanlopes
Advocate I
Advocate I

"BadRequestException: The request was denied, it contains illegal input: ''"

Hello everyone,

I am trying to upload and import a PBIX file programmatically to a Power BI workspace using the Power BI REST API with the new "createTemporaryUploadLocation" method. The process is:

  1. Acquire Azure AD token using @Azure/msal-node

  2. Request a temporary upload URL from the API

  3. Upload the PBIX file directly to the given Azure Blob Storage URL using an HTTP PUT request

  4. Call the Power BI import API with the fileUrl pointing to the uploaded blob

The upload itself completes successfully (status 201), but when I call the import API, I receive the following error:

 

{
"code": "BadRequestException",
"message": "The request was denied, it contains illegal input: ''"
}

The full error details show a 400 Bad Request, but no indication of what input is illegal.

const axios = require('axios');
const { ConfidentialClientApplication } = require('@azure/msal-node');
const path = require('path');
const fs = require('fs');

const TENANT_ID = 'xxxx-xxxx-xxxx-xxxx';
const CLIENT_ID = 'xxxx-xxxx-xxxx-xxxx';
const CLIENT_SECRET = 'xxxxxx';
const GROUP_ID = 'xxxx-xxxx-xxxx-xxxx';
const FILE_PATH = '/path/to/file.pbix';

const POWERBI_API_BASE_URL = 'https://api.powerbi.com/v1.0/myorg';
const TEMP_UPLOAD_LOCATION_URL = `${POWERBI_API_BASE_URL}/groups/${GROUP_ID}/imports/createTemporaryUploadLocation`;

async function importLargePBIX() {
try {
const cca = new ConfidentialClientApplication({
auth: { clientId: CLIENT_ID, authority: `https://login.microsoftonline.com/${TENANT_ID}`, clientSecret: CLIENT_SECRET },
});
const tokenResponse = await cca.acquireTokenByClientCredential({
scopes: ['https://analysis.windows.net/powerbi/api/.default'],
});
const accessToken = tokenResponse.accessToken;
const headers = { Authorization: `Bearer ${accessToken}`, 'Content-Type': 'application/json' };

// Get temporary upload URL
const tempLocationResponse = await axios.post(TEMP_UPLOAD_LOCATION_URL, {}, { headers });
const uploadUrl = tempLocationResponse.data.url;

// Upload PBIX file to the blob storage URL
const fileBuffer = fs.readFileSync(FILE_PATH);
await axios.put(uploadUrl, fileBuffer, {
headers: { 'Content-Type': 'application/octet-stream', 'x-ms-blob-type': 'BlockBlob' },
maxContentLength: Infinity,
maxBodyLength: Infinity,
});

// Import dataset referencing uploaded PBIX URL
const importApiUrl = `${POWERBI_API_BASE_URL}/groups/${GROUP_ID}/imports?datasetDisplayName=MyDataset&nameConflict=Overwrite`;
const bodyPost = { fileUrl: uploadUrl };

const importResponse = await axios.post(importApiUrl, bodyPost, { headers });
console.log('Import successful:', importResponse.data);
} catch (error) {
console.error('Import error:', error.response ? error.response.data : error.message);
}
}

importLargePBIX();

Question:

  • Has anyone encountered this "illegal input: ''" error when importing PBIX via fileUrl?

  • Is there any missing or malformed data in the import API call?

  • Is the fileUrl supposed to be the exact temporary upload URL received, or does it need some modification?

  • Any suggestions on how to resolve this?

Thanks in advance for your help!

19 REPLIES 19
Shubham_buddy
Regular Visitor


Getting this issue.
{
"error": {
"code": "InvalidFileSizeError",
"pbi.error": {
"code": "InvalidFileSizeError",
"parameters": {
"FileSize": "782546990"
},
"details": [],
"exceptionCulprit": 1
}
}
}

It is working for me now, We need a PBIX file more than 1 GB.

Shubham_buddy
Regular Visitor


After following the above steps. in last step to import the file back to powerbI workspace I am getting below issue.
How I can resolve this?
{
"error": {
"code": "PowerBIInvalidOrCorruptPbixFileError",
"pbi.error": {
"code": "PowerBIInvalidOrCorruptPbixFileError",
"parameters": {},
"details": [],
"exceptionCulprit": 1
}
}
}

BhumitraSharma
Frequent Visitor

Hey, I surprisingly got stuck with the same issue. I am trying the following steps:
1. I save my PBIX file (around 500 mb) on a storage account with public access.
2. I send my FileUrl and the rest of the params as You have mentioned.
3. I make the post request and get the error as 'message': "The request was denied, it contains illegal input: ''"

Was there any useful solution found?

Hey did you get the resolution for this using Python? Please share the code with me buddy.

Hi @BhumitraSharma ,

Yes, I was able to resolve the issue with help from Microsoft Support. I had to follow these steps:

1. Generate a Temporary Upload Link

If your PBIX file is 1GB or larger, you need to generate a temporary upload link using the documentation below:

🔗 Create Temporary Upload Location in Group (Power BI REST API)

Headers:

 

Content-Type: application/json

 

Request Body Example:

 

{
  "datasetDisplayName": "greaterFile.pbix"
}

 

2. Upload the PBIX File Using PowerShell

Use the generated SAS URL from Step 1 in the PowerShell script below to upload the file:

 

# Define the path to your .pbix file
$pbixFilePath = "C:\Path\To\Your\LargeReport.pbix"

# Paste your SAS URL from Step 1 here
$sasUrl = "https://<storage>.blob.core.windows.net/<container>/<filename>.pbix?<SAS_TOKEN>"

# Read the file content
$fileContent = Get-Content -Path $pbixFilePath -Encoding Byte -ReadCount 0

# Create headers
$headers = @{
    "x-ms-blob-type" = "BlockBlob"
    "Content-Type"   = "application/octet-stream"
}

# Upload the file using PUT
Invoke-RestMethod -Uri $sasUrl -Method Put -Body $fileContent -Headers $headers

 

3. Trigger the Import via REST API

After uploading the file, trigger the dataset import using the Post Import In Group endpoint:

🔗 Post Import In Group (Power BI REST API)

In Postman (or any API tool), provide:

  • Group ID

  • datasetDisplayName (ensure the name ends with .pbix)

Headers:

 

Content-Type: application/json

 

Request Body Example:

{
  "fileUrl": "<SAS_URL_FROM_STEP_2>"
}

If your PBIX file is smaller than 1GB, you don’t need to generate a temporary upload link.
You can directly use the same Post Import In Group endpoint:
🔗 Post Import In Group (Power BI REST API)

Best regards,

@luanlopes Thanks a ton for spending time on this.

I am using a python script very similar to the solution you have mentioned. I use an Azure Service Principal to extract a authorization token. I then call the following code to create a temporaryStorageLocation:

 

temp_upload_url_endpoint = f"https://api.powerbi.com/v1.0/myorg/groups/{group_id}/imports/createTemporaryUploadLocation"

upload_url_response = requests.post(temp_upload_url_endpoint, headers=headers)
upload_url_response.raise_for_status()

 
This function returns back with a URL that I am saving as the SAS URL that I need to upload my file to. Once I get this URL I use my PBIX file and upload it using the following code:
 
with open(PBIX_FILE_PATH, 'rb') as f:
    upload_headers = {
       "x-ms-blob-type": "BlockBlob",
       "Content-Type": "application/octet-stream"
    }
    upload_response = requests.put(upload_url, data=f, headers=upload_headers)

This returns a 201 response and the upload is sucesfull. Considering its a SAS Url, I cannot confirm by going to the URL as its write only and not allowing read access. 

Once I am done with this, I make the following API call from my python code:
 

import_endpoint = f"https://api.powerbi.com/v1.0/myorg/groups/{group_id}/imports?datasetDisplayName={PBIX_NAME}&nameConf..."

import_headers = {
    "Authorization": f"Bearer {access_token}",
    "Content-Type": "application/json"
}

import_body = {
    "fileUrl": upload_url
    }

import_response = requests.post(import_endpoint, headers=import_headers, json=import_body)

My pbix name ends with .pbix (its a random name). This is the api that ends up failing. I tried with Postman where it gave me 403 forbiden. Here on python it gives me the error as:

b'{"error":{"code":"InvalidFileSizeError","pbi.error":{"code":"InvalidFileSizeError","parameters":{"FileSize":"479063600"},"details":[],"exceptionCulprit":1}}}'
 
This maybe because my current file is ~500Mb and I need to figure out how to bloat it beyond 1 Gb. 

Were you able to use this method for files below 1Gb? Also do you always perform the upload to the SAS Url via uploading the file or can we transfer the file from one azure storage account bucket to this SAS location directly. My goal is to avoid taking a heavy pbix file onto the machine that runs my main microservice.
 
Again, thanks a ton for responding to my queries its been very very helpful. 

Hello @BhumitraSharma , 
I am facing similar issue like You can you please let me know what resolution you got?

 

Thanks

Hi, 

If you want to use this solution, your file must be smaller than 1GB. This solution is necessary when the file is larger than 1GB.

Hi Luanlopes, I tried your steps and created a scratch code in Python to perform step1 (Create temporary storage location) and step2: Upload pbix file (My file was under 1Gb for now). When I try step3, which is import from fileUrl I am now getting a different error:

b'{"code":"BadRequestException","message":"The request was denied, it contains illegal input: \'\'"}'

Did you face something similar too? I later on tried with another file of about 500Mb and this time got the error as:
b'{"error":{"code":"InvalidFileSizeError","pbi.error":{"code":"InvalidFileSizeError","parameters":{"FileSize":"479063600"},"details":[],"exceptionCulprit":1}}}'

I think this could be due to the 1Gb lower limit. I'll try and respond if it works. 

Hi @BhumitraSharma

I’ve prepared an example script that you can use to test this solution. I’ll share it below: 

 

#!/bin/bash

# ===============================
# Power BI PBIX Upload Using CURL (macOS/Linux)
# Author: Adapted for Luan Lopes
# ===============================
# Requirements: curl
# ===============================

# === CONFIGURATION ===
PBIX_FILE="your_pbix_file_path"
SAS_URL="your_sas_url"

# Check if file exists
if [ ! -f "$PBIX_FILE" ]; then
  echo "❌ PBIX file not found at: $PBIX_FILE"
  exit 1
fi

# Upload the file using PUT
echo "⏫ Uploading PBIX using curl PUT..."
curl -X PUT \
  -T "$PBIX_FILE" \
  -H "x-ms-blob-type: BlockBlob" \
  -H "Content-Type: application/octet-stream" \
  "$SAS_URL"

if [ $? -eq 0 ]; then
  echo "✅ Upload completed successfully!"
else
  echo "❌ Upload failed!"
  exit 1
fi

 

 
After uploading the file, use the following endpoint to import it: 

 

POST https://api.powerbi.com/v1.0/myorg/groups/{groupID}/imports?datasetDisplayName=Taxboard ICMS - Dexco.pbix&nameConflict=Overwrite

 

Make sure to replace datasetDisplayName with the actual .pbix file name (e.g., your_pbix_file.pbix) and ensure nameConflict=Overwrite is set to avoid conflicts.

Let me know if you need anything else!

Example:

luanlopes_0-1754391451836.png

 

Thankyou so much for the detailed response. Let me try these steps. Hopefully they will resolve the issue.

Nasif_Azam
Super User
Super User

Hey @luanlopes ,

This error typically indicates that the Power BI REST API is receiving a missing or incorrectly formatted parameter but unfortunately, the message doesn’t specify which one. Here's a thorough breakdown of possible issues and how to resolve them.

 

What Might Be Causing the Issue

1. fileUrl Must Be the sasUri (Not url)

Power BI's createTemporaryUploadLocation response returns an object that includes sasUri and fileUploadState. You must use the sasUri in the import call:

const uploadUrl = tempLocationResponse.data.sasUri;

You're currently using tempLocationResponse.data.url, which is likely incorrect or empty hence the illegal input: '' error.

 

2. Body Format Must Match Expected Schema

When calling the import API with a fileUrl, your body must include:

{
  "fileUrl": "<SAS URL>",
  "datasetDisplayName": "MyDataset",
  "nameConflict": "Overwrite"
}

But in your current code, you're passing datasetDisplayName and nameConflict as query parameters, not in the body.

 

Fix:

const importApiUrl = `${POWERBI_API_BASE_URL}/groups/${GROUP_ID}/imports`;
const bodyPost = {
  fileUrl: uploadUrl,
  datasetDisplayName: "MyDataset",
  nameConflict: "Overwrite"
};
const importResponse = await axios.post(importApiUrl, bodyPost, { headers });

 

Updated Code Fixes

// Get temporary upload URL
const tempLocationResponse = await axios.post(TEMP_UPLOAD_LOCATION_URL, {}, { headers });
const uploadUrl = tempLocationResponse.data.sasUri; // use sasUri instead of url

// Upload PBIX file
await axios.put(uploadUrl, fileBuffer, {
  headers: {
    'Content-Type': 'application/octet-stream',
    'x-ms-blob-type': 'BlockBlob'
  },
  maxContentLength: Infinity,
  maxBodyLength: Infinity,
});

// Call Import API
const importApiUrl = `${POWERBI_API_BASE_URL}/groups/${GROUP_ID}/imports`;
const bodyPost = {
  fileUrl: uploadUrl,
  datasetDisplayName: 'MyDataset',
  nameConflict: 'Overwrite'
};

const importResponse = await axios.post(importApiUrl, bodyPost, { headers });
console.log('Import successful:', importResponse.data);

 

In Short:

Using url instead of sasUri (Replace tempLocationResponse.data.url with .sasUri)

Passing parameters in URL (Pass datasetDisplayName and nameConflict in the request body)

Empty string error (Likely due to fileUrl being '' or malformed)

 

If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.


Best Regards,
Nasif Azam



Did I answer your question?
If so, mark my post as a solution!
Also consider helping someone else in the forums!

Proud to be a Super User!


LinkedIn

Hey @Nasif_Azam, thank you very much for the response!


1. When I call the endpoint

${POWERBI_API_BASE_URL}/groups/${GROUP_ID}/imports/createTemporaryUploadLocation

to create a temporary upload location, the response is:

Creating temporary upload location...
Complete tempLocationResponse: {
  "@odata.context": "https://api.powerbi.com/v1.0/myorg/groups/*****/$metadata#Microsoft.PowerBI.ServiceContracts.Api.temporaryUploadLocation",
  "url": "https://*******",
  "expirationTime": "2025-06-18T22:11:38.0591596Z"
}

but I don’t receive a sasUri parameter to use afterward.

2. Regarding datasetDisplayName and nameConflict, I’m using them as query parameters because I was following the documentation. I also tested sending them in the body, but it still didn’t work.

 

here the full log:

Access token obtained successfully.
Creating temporary upload location...
Complete tempLocationResponse: {
  "@odata.context": "https://api.powerbi.com/v1.0/myorg/groups/*********/$metadata#Microsoft.PowerBI.ServiceContracts.Api.temporaryUploadLocation",
  "url": "https://wabibrasbppbiv2.blob.core.windows.net/{container}/{folder}/Import/{fileId}?skoid=***&sktid=***&skt=2025-06-18T21:11:38Z&ske=2025-06-19T21:11:38Z&sks=b&skv=2024-08-04&sv=2024-08-04&se=2025-06-18T22:11:38Z&sr=b&sp=w&sig=***"",
  "expirationTime": "2025-06-18T22:11:38.0591596Z"
}
Starting PBIX file upload...
File size: 43.97 MB
Upload progress: 0%
Upload progress: 100%
PBIX file upload completed successfully!
Upload status: 201
Waiting for file processing...
Starting dataset import in Power BI...
An error occurred during the import process: {
  code: 'BadRequestException',
  message: "The request was denied, it contains illegal input: ''"
}
Error status: 400
Error headers: {
  'content-length': '96',
  'content-type': 'application/json; charset=utf-8',
  ...
}
Complete error data: {
  "code": "BadRequestException",
  "message": "The request was denied, it contains illegal input: ''"
}

i tried executing the steps you mentioned, but they aren’t working for me. I have some screenshots and context, but it’s a bit strange.

I'm using this documentation to create a temporary location: https://learn.microsoft.com/pt-br/rest/api/power-bi/imports/create-temporary-upload-location-in-grou...

best regards,

Hey @luanlopes ,

Thanks for the detailed. You're right your url is the correct SAS URL. They’ve renamed sasUri to url in the latest API). The issue is likely with how you're passing parameters.

 

Try this minimal fix:

const importApiUrl = `${POWERBI_API_BASE_URL}/groups/${GROUP_ID}/imports`;
const bodyPost = {
  fileUrl: uploadUrl, // from tempLocationResponse.data.url
  datasetDisplayName: "MyDataset",
  nameConflict: "Overwrite"
};

const importResponse = await axios.post(importApiUrl, bodyPost, {
  headers: {
    ...headers,
    'Content-Type': 'application/json' // ensure this is set for POST body
  }
});

Don’t use query params for datasetDisplayName or nameConflict.

 

 

If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.


Best Regards,
Nasif Azam



Did I answer your question?
If so, mark my post as a solution!
Also consider helping someone else in the forums!

Proud to be a Super User!


LinkedIn

Hello @Nasif_Azam

Sorry for the delay. I tried the suggested solution, but unfortunately it didn’t work for me. I’ve opened a support ticket with Microsoft to resolve the issue and am currently awaiting their response.

Hi  @luanlopes 

I wanted to follow up regarding the support ticket you opened with Microsoft. I understand that these issues can take time to resolve, but I wanted to check in and see if you have received any updates from their team.

If there’s anything else I can assist you with in the meantime, please feel free to let me know.

Thank you,  I look forward to hearing from you soon!

 

Hi  @luanlopes 

I wanted to follow up on your inquiry regarding the "BadRequestException" error when importing a PBIX file via the Power BI REST API. I provided some guidance on how to adjust your API call to resolve the issue.

As we haven't received a response yet, I wanted to remind you that it's important to keep the discussion active for the benefit of the community. If you could take a moment to test the suggested changes and provide feedback, it would be greatly appreciated.

if the issue is resolved accept the solution.
Thank you for your understanding!

 

Hello @luanlopes 

I’m following up on your recent issue where you received a BadRequestException while importing your PBIX via the Power BI REST API. I shared some modifications to your API call configuration that should resolve this error.

Since we haven’t heard back yet, I wanted to check if you’ve had a chance to test the suggested changes. Your feedback is invaluable—not just for you, but for everyone in the community facing similar scenarios.

If the solution worked, please mark it as the Accepted Answer. If you’re still seeing issues or need further assistance, feel free to drop your feedback or error details here, and we’ll help you troubleshoot further.

Thanks for your time and collaboration.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.