<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic REST import rdl files in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/REST-import-rdl-files/m-p/708986#M19592</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working on an automated deployment solution in powershell to import to PowerBI using the REST API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have borrowed the function at this URL and am able to import pbix files without any problems:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Microsoft/powerbi-powershell/issues/46" target="_blank" rel="noopener"&gt;https://github.com/Microsoft/powerbi-powershell/issues/46&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;function Publish-PowerBIImport {
    param
    (
        [string]$Path,
        [string]$GroupId
    )

    $powerBiBodyTemplate = @'
--{0}
Content-Disposition: form-data; name="fileData"; filename="{1}"
Content-Type: application/x-zip-compressed

{2}
--{0}--

'@

    $fileName = [IO.Path]::GetFileName($Path)
    $boundary = [guid]::NewGuid().ToString()
    $fileBytes = [System.IO.File]::ReadAllBytes($Path)
    $encoding = [System.Text.Encoding]::GetEncoding("iso-8859-1")
    $filebody = $encoding.GetString($fileBytes)
    $body = $powerBiBodyTemplate -f $boundary, $fileName, $encoding.GetString($fileBytes)

    $headers = Get-PowerBIAccessToken

    if ($GroupId) {
        $url = "https://api.powerbi.com/v1.0/myorg/groups/$GroupId/imports?datasetDisplayName=$fileName&amp;amp;nameConflict=CreateOrOverwrite"
    }
    else {
        $url = "https://api.powerbi.com/v1.0/myorg/imports?datasetDisplayName=$fileName&amp;amp;nameConflict=CreateOrOverwrite"
    }

    Invoke-RestMethod -Uri $url -Method Post -Headers $headers -Body $body -ContentType "multipart/form-data; boundary=--$boundary" | Out-Null
    Write-Host "Imported Power BI file $Path"
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when I feed this function a rdl file, I get the following error:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Invoke-RestMethod :&lt;BR /&gt;{"error":{"code":"ImportUnsupportedOptionError","pbi.error":{"code":"ImportUnsupportedOptionError","parameters":{},"details":[],"exceptionCulprit":1}}}&lt;BR /&gt;At G:\Visual Studio Projects\PowerShell Scripts\PowerBIDeployment.ps1:34 char:5&lt;BR /&gt;+ Invoke-RestMethod -Uri $url -Method Post -Headers $headers -Body ...&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException&lt;BR /&gt;+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have modified the Content-Type header and the encoding to suit the rdl file, as below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;function Publish-PowerBIImport {
    param
    (
        [string]$Path,
        [string]$GroupId
    )

    $powerBiBodyTemplate = @'
--{0}
Content-Disposition: form-data; name="fileData"; filename="{1}"
Content-Type: text/xml

{2}
--{0}--

'@

    $fileName = [IO.Path]::GetFileName($Path)
    $boundary = [guid]::NewGuid().ToString()
    $fileBytes = [System.IO.File]::ReadAllBytes($Path)
    $encoding = [System.Text.Encoding]::GetEncoding("utf-8")
    $filebody = $encoding.GetString($fileBytes)
    $body = $powerBiBodyTemplate -f $boundary, $fileName, $encoding.GetString($fileBytes)

    $headers = Get-PowerBIAccessToken

    if ($GroupId) {
        $url = "https://api.powerbi.com/v1.0/myorg/groups/$GroupId/imports?datasetDisplayName=$fileName&amp;amp;nameConflict=CreateOrOverwrite"
    }
    else {
        $url = "https://api.powerbi.com/v1.0/myorg/imports?datasetDisplayName=$fileName&amp;amp;nameConflict=CreateOrOverwrite"
    }

    Invoke-RestMethod -Uri $url -Method Post -Headers $headers -Body $body -ContentType "multipart/form-data; boundary=--$boundary" | Out-Null
    Write-Host "Imported Power BI file $Path"
}&lt;/PRE&gt;&lt;P&gt;The error code suggests rdl import may not yet be supported in this manner, can anyone confirm/deny? Cheers.&lt;/P&gt;</description>
    <pubDate>Fri, 07 Jun 2019 02:02:21 GMT</pubDate>
    <dc:creator>BenTheSmaller</dc:creator>
    <dc:date>2019-06-07T02:02:21Z</dc:date>
    <item>
      <title>REST import rdl files</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/REST-import-rdl-files/m-p/708986#M19592</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working on an automated deployment solution in powershell to import to PowerBI using the REST API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have borrowed the function at this URL and am able to import pbix files without any problems:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Microsoft/powerbi-powershell/issues/46" target="_blank" rel="noopener"&gt;https://github.com/Microsoft/powerbi-powershell/issues/46&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;function Publish-PowerBIImport {
    param
    (
        [string]$Path,
        [string]$GroupId
    )

    $powerBiBodyTemplate = @'
--{0}
Content-Disposition: form-data; name="fileData"; filename="{1}"
Content-Type: application/x-zip-compressed

{2}
--{0}--

'@

    $fileName = [IO.Path]::GetFileName($Path)
    $boundary = [guid]::NewGuid().ToString()
    $fileBytes = [System.IO.File]::ReadAllBytes($Path)
    $encoding = [System.Text.Encoding]::GetEncoding("iso-8859-1")
    $filebody = $encoding.GetString($fileBytes)
    $body = $powerBiBodyTemplate -f $boundary, $fileName, $encoding.GetString($fileBytes)

    $headers = Get-PowerBIAccessToken

    if ($GroupId) {
        $url = "https://api.powerbi.com/v1.0/myorg/groups/$GroupId/imports?datasetDisplayName=$fileName&amp;amp;nameConflict=CreateOrOverwrite"
    }
    else {
        $url = "https://api.powerbi.com/v1.0/myorg/imports?datasetDisplayName=$fileName&amp;amp;nameConflict=CreateOrOverwrite"
    }

    Invoke-RestMethod -Uri $url -Method Post -Headers $headers -Body $body -ContentType "multipart/form-data; boundary=--$boundary" | Out-Null
    Write-Host "Imported Power BI file $Path"
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when I feed this function a rdl file, I get the following error:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Invoke-RestMethod :&lt;BR /&gt;{"error":{"code":"ImportUnsupportedOptionError","pbi.error":{"code":"ImportUnsupportedOptionError","parameters":{},"details":[],"exceptionCulprit":1}}}&lt;BR /&gt;At G:\Visual Studio Projects\PowerShell Scripts\PowerBIDeployment.ps1:34 char:5&lt;BR /&gt;+ Invoke-RestMethod -Uri $url -Method Post -Headers $headers -Body ...&lt;BR /&gt;+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~&lt;BR /&gt;+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException&lt;BR /&gt;+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have modified the Content-Type header and the encoding to suit the rdl file, as below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;function Publish-PowerBIImport {
    param
    (
        [string]$Path,
        [string]$GroupId
    )

    $powerBiBodyTemplate = @'
--{0}
Content-Disposition: form-data; name="fileData"; filename="{1}"
Content-Type: text/xml

{2}
--{0}--

'@

    $fileName = [IO.Path]::GetFileName($Path)
    $boundary = [guid]::NewGuid().ToString()
    $fileBytes = [System.IO.File]::ReadAllBytes($Path)
    $encoding = [System.Text.Encoding]::GetEncoding("utf-8")
    $filebody = $encoding.GetString($fileBytes)
    $body = $powerBiBodyTemplate -f $boundary, $fileName, $encoding.GetString($fileBytes)

    $headers = Get-PowerBIAccessToken

    if ($GroupId) {
        $url = "https://api.powerbi.com/v1.0/myorg/groups/$GroupId/imports?datasetDisplayName=$fileName&amp;amp;nameConflict=CreateOrOverwrite"
    }
    else {
        $url = "https://api.powerbi.com/v1.0/myorg/imports?datasetDisplayName=$fileName&amp;amp;nameConflict=CreateOrOverwrite"
    }

    Invoke-RestMethod -Uri $url -Method Post -Headers $headers -Body $body -ContentType "multipart/form-data; boundary=--$boundary" | Out-Null
    Write-Host "Imported Power BI file $Path"
}&lt;/PRE&gt;&lt;P&gt;The error code suggests rdl import may not yet be supported in this manner, can anyone confirm/deny? Cheers.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2019 02:02:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/REST-import-rdl-files/m-p/708986#M19592</guid>
      <dc:creator>BenTheSmaller</dc:creator>
      <dc:date>2019-06-07T02:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: REST import rdl files</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/REST-import-rdl-files/m-p/907300#M22073</link>
      <description>&lt;P&gt;The problem with your code is the value of the nameConflict parameter:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$url = "https://api.powerbi.com/v1.0/myorg/groups/$GroupId/imports?datasetDisplayName=$fileName&amp;amp;nameConflict=CreateOrOverwrite"&lt;/PRE&gt;&lt;P&gt;For RDL files, the only supported values are Abort or Overwrite.&lt;/P&gt;&lt;P&gt;There is, however, a bug in that we are not returning a helpful error message.&amp;nbsp; We are looking in to fixing this in a future release.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Teresa (MSFT)&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 02:52:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/REST-import-rdl-files/m-p/907300#M22073</guid>
      <dc:creator>TeresaL</dc:creator>
      <dc:date>2020-01-22T02:52:03Z</dc:date>
    </item>
    <item>
      <title>Re: REST import rdl files</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/REST-import-rdl-files/m-p/962014#M22611</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to upload&amp;nbsp; a rdl file to a workspace programatically through Power BI rest API in a .net solution. We are using Power BI .net SDK to acheive this functionality. We are using "PostImportWithFileAsyncInGroup" method to upload the rdl file but getting "&lt;STRONG&gt;Badrequest&lt;/STRONG&gt;" error all the time. I&amp;nbsp; have verified that the capacity has been set "A4" and the Paginated workload is also turned on. It would be really helpful if somebody can shed some light on this issue.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2020 10:40:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/REST-import-rdl-files/m-p/962014#M22611</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-06T10:40:27Z</dc:date>
    </item>
  </channel>
</rss>

