<?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 Re: Decoding binary version of excel from REST api call response in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Decoding-binary-version-of-excel-from-REST-api-call-response/m-p/1958908#M30523</link>
    <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;I'd like to suggest you trace the exported file to confirm the file format and encode before you do transform operations.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;In addition, this API also includes the limit of exported file format, I'd like to suggest you check the original report and exported file format at the first.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jul 2021 06:13:04 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-07-15T06:13:04Z</dc:date>
    <item>
      <title>Decoding binary version of excel from REST api call response</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Decoding-binary-version-of-excel-from-REST-api-call-response/m-p/1954111#M30492</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi I have folowing powershell script where I sent REST API calls:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;$groupId = ''
$reportId = ''
$exportFormat = 'XLSX'

$body = '{ format: "' + $exportFormat + '" }'

## Reports - Export To File In Group
$Export = Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/groups/$groupId/reports/$reportId/ExportTo" -Method Post -Body $body
$vExport = $Export | ConvertFrom-Json
$exportId = $vExport.id

## Pooling information
$Status = Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/groups/$groupId/reports/$reportId/exports/$exportId" -Method Get
$vStatus = $Status | ConvertFrom-Json
$vStatus

## Reports - Get File Of Export To File In Group
$File = Invoke-PowerBIRestMethod -Url "https://api.powerbi.com/v1.0/myorg/groups/$groupId/reports/$reportId/exports/$exportId/file" -Method Get

$BodyBytes = [System.Text.Encoding]::UTF8.GetBytes($File)

[System.IO.MemoryStream]$memoryStream = New-Object System.IO.MemoryStream(, $BodyBytes)
$memoryStream.Position = 0
[System.Net.Mime.ContentType]$contentType = New-Object System.Net.Mime.ContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")

[System.Net.Mail.Attachment]$attachment = New-Object Mail.Attachment($memoryStream, $contentType)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;SPAN&gt;And then I send email with attachment. Problem is, that attach file is damaged after email reciving. I guess I'm not working correctly with converting $File to Bytes[]. Do you know how to work with binary version of excel?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jul 2021 08:39:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Decoding-binary-version-of-excel-from-REST-api-call-response/m-p/1954111#M30492</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-13T08:39:17Z</dc:date>
    </item>
    <item>
      <title>Re: Decoding binary version of excel from REST api call response</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Decoding-binary-version-of-excel-from-REST-api-call-response/m-p/1958908#M30523</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;I'd like to suggest you trace the exported file to confirm the file format and encode before you do transform operations.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;In addition, this API also includes the limit of exported file format, I'd like to suggest you check the original report and exported file format at the first.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 06:13:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Decoding-binary-version-of-excel-from-REST-api-call-response/m-p/1958908#M30523</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-15T06:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: Decoding binary version of excel from REST api call response</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Decoding-binary-version-of-excel-from-REST-api-call-response/m-p/1958978#M30524</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Of course I have checked the original file. It exports correctly. Even when I pipe file output via -OutFile excel works fine. Problem is I guess with the object $File. It may not be the correct object type. Rest API documentation says, that response is in format Media Type. So for xlsx files it could be:&lt;/P&gt;&lt;PRE&gt;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;but powershell returns type error when I try to save it to that object.&lt;BR /&gt;&lt;BR /&gt;I'm doing this to create subscriptions on top of paginated reports so we could decommission our SQL Server Reporting Services. I don't want to add another step to save file, wanna do it all in memory.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 06:35:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Decoding-binary-version-of-excel-from-REST-api-call-response/m-p/1958978#M30524</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-07-15T06:35:45Z</dc:date>
    </item>
  </channel>
</rss>

