Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

multipartmimestreamformatexception error when importing pbix files using rest api



So I'm using powershell to automate my power BI reports into my workspace through imports API.

here's the code which I'm using :

    $PBIXuri="my azure blob storage url",
    $AccessToken="my oauth token"

    #download my pbix file from azure blob storage
    $cli = New-Object System.Net.WebClient
    $exportpbix = $cli.DownloadData($PBIXuri)

    $powerBiBody = @'
    Content-Disposition: form-data; name="file";
    Content-Type: application/x-zip-compressed



    #set my pbix file into request body
    $encoding = [System.Text.Encoding]::GetEncoding('iso-8859-1')
    $body = $powerBiBody -f $encoding.GetString($exportpbix)

    $headers = @{
    "Authorization" = "Bearer " + $AccessToken}

    Invoke-RestMethod -Uri $Workspaceurl -Method Post -Headers $headers -Body $body -ContentType "multipart/form-data; boundary=--exptest"


but it always return an error like :


Invoke-RestMethod :     {"error":


where do I went wrong on my code?

Helpful resources

New Ranks Launched March 24th!

New Ranks Launched March 24th!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power BI Community!

‘Better Together’ Contest Finalists Announced!

‘Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Arun 'Triple A' Event Video, Q&A, and Slides

Arun 'Triple A' Event Video, Q&A, and Slides

Missed the Arun 'Triple A' event or want to revisit it? We've got you covered! Check out the video, Q&A, and slides now.

Top Solution Authors