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')} } ] }
Any ideas at all? Spent some more time looking at this and still getting nowhere!
Thanks,
Hi Anonymous ,
I found the very useful blogs yesterday. Maybe they also can help you.
Please reference:
Calling The Power BI Export API From Power Automate, Part 1: Creating A Custom Connector
- Anonymous6 years agoNot applicable
Thanks v-xuding-msft
These are indeed very helpful, and I've spent a lot of time looking at these to get me as far as I have, but do not help with my specific issue.
Pretty much the only thing I think I am missing, is what do I need to do with the output of the export step, before injecting it into the import step. It's probably as simple as a compose with some text to define something, but I just cannot figure it out.
Thanks,
Tom.
- cwebb6 years agoAdvocate V
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
- Anonymous6 years agoNot applicable
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.