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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
raviShekhar404
Regular Visitor

Uploading a PBIX file using the import API in nodejs

Hi folks,

I am facing issue while uploading a PBIX file from local storage using import API. Code is in nodejs. Please find snipshot below

 

let options = {
    method: 'POST',
    headers: {
        'Content-Type': 'multipart/form-data',
        'authorization': 'Bearer ' + authToken
    },
    body: fs.createReadStream(filePathOnLocal + 'report.pbix'),
    url: `https://api.powerbi.com/v1.0/myorg/groups/${group_id}/imports?datasetDisplayName=report.pbix&nameConflict=CreateOrOverwrite`
};
const result = await axios.request(options)

 

 

It is giving me error

raviShekhar404_0-1702617813947.png

 

I had found same code in other post, but not sure why I am facing this issue.

Also for verify if file is correct or not, I have called PBI API directly from Postman with same file and it successfully upload the file on desired group. Only for code it is failing

 

1 ACCEPTED SOLUTION
raviShekhar404
Regular Visitor

Issue fixed, from one of the post I come to know that Content-Lenght is required to append in headers.

Attaching link of that post
'Post in Group' API using Nodejs - Microsoft Fabric Community

Happy sharing

View solution in original post

2 REPLIES 2
raviShekhar404
Regular Visitor

One more observation, with axios only we have to do these changes. Because I have tried with request library(depricated in nodejs) also and it works fine.

let options:any = {
method: 'POST',
headers: {
'authorization': 'Bearer ' + authToken
},
data:{
"file":{"value":fs.createReadStream(filePath),"options":{"filename":"report.pbix","contentType":null}},
},
url: url
};
const result = await request(options)
console.log(result)
raviShekhar404
Regular Visitor

Issue fixed, from one of the post I come to know that Content-Lenght is required to append in headers.

Attaching link of that post
'Post in Group' API using Nodejs - Microsoft Fabric Community

Happy sharing

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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