Forum Discussion
'Post in Group' API using Nodejs
Hi nfadili , did you sort this out.
I'm having the exact same message issue using Axios (I guess FileSize: '9223372036854775807' means infinite?). Mi pbix file size i s just 194KB
My code is quite similar to yours
async postImportInGroup(groupId, datasetDisplayName) {
try {
let AccessToken = await auth.getMicrosoftToken();
var formData = new FormData();
formData.append(datasetDisplayName, fs.createReadStream(__basedir +'/pbix/workspace-master.pbix'));
var headers = formData.getHeaders();
headers['Authorization'] = `Bearer ${AccessToken}`;
headers['content-type'] = 'multipart/form-data'
const options = {
method: 'POST',
headers: headers,
data: formData,
url: Mustache.render("https://api.powerbi.com/v1.0/myorg/groups/{{groupId}}/imports?datasetDisplayName={{datasetDisplayName}}", { groupId: groupId, datasetDisplayName: datasetDisplayName }),
};
let response = await axios(options)
return response.data
}cheers
- nfadili5 years agoFrequent Visitor
Hey dpiret,
I ended up contacting MSFT support about this issue shortly after posting here. They told me that the Content-Length header is required but is not listed in their documentation https://docs.microsoft.com/en-us/rest/api/power-bi/imports/post-import-in-group - they also told me that they would update the documentation to include this detail but have not done so.
I am still using the method I described above (write the file to disk, calculate length, submit, delete from disk) but I would prefer not to. If you figure anything else out please share 🙂