Forum Discussion
PowerBI - REST API - Export and then Import in Flow / Power Automate
- 6 years ago
Hi Anonymous ,
i found the solution.
To import a file, request Headers should include Content-Type: multipart/form-data with the file encoded as form data in the request body.
{ "$content-type": "multipart/form-data", "$multipart": [ { "body": @{body('Export_PBIX')} } ] }
Does your import step work with a pbix file that you haven't just exported, ie one that you've built yourself in Power BI Desktop?
The only other thing I can suggest is to look at this example of how to call the export/import endpoints in PowerShell, which might highlight something that you're doing wrong:
https://github.com/Azure-Samples/powerbi-powershell/blob/master/copyWorkspace.ps1
HTH,
Chris
Hi cwebb
Thanks for looking at this.
I have indeed tried manually too, still failing. From looking at the powershell it looks like the bit that I'm missing is the conversion to the multipart form data:
$packageFileStream = New-Object System.IO.FileStream @($temp_path, [System.IO.FileMode]::Open)
$contentDispositionHeaderValue = New-Object System.Net.Http.Headers.ContentDispositionHeaderValue "form-data"
$contentDispositionHeaderValue.Name = "file0"
$contentDispositionHeaderValue.FileName = $file_name
$streamContent = New-Object System.Net.Http.StreamContent $packageFileStream
$streamContent.Headers.ContentDisposition = $contentDispositionHeaderValue
$content = New-Object System.Net.Http.MultipartFormDataContent
$content.Add($streamContent)
Any ideas how to do that in Flow?
Thanks,
Tom.