Quantcast
Channel: Service topics
Viewing all articles
Browse latest Browse all 62213

Power BI REST API ExportTo MHTML leads to a base64 encoded file

$
0
0

I am using a Python Notebook to export Paginated Reports to an HTML file. Now it works fine for CSV files, I get clear and readable CSV back, the same goes for IMAGE with the format set to PNG. But when I set the format to MHTML as per the documentation I am getting a long error response about my headers, followed by a succesfull download of a file with .html extension. If I open it however it doesn't look like HTML:

 

MIME-Version: 1.0
Content-Type: multipart/related;
boundary="----=_NextPart_01C35DB7.4B204430"
X-MSSQLRS-ProducerVersion: V
 
This is a multi-part message in MIME format.
 
------=_NextPart_01C35DB7.4B204430
Content-ID: <filename>
Content-Disposition: inline;
filename="filename"
Content-Type: text/html;
name="filename";
charset="utf-8"
Content-Transfer-Encoding: base64
 
PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMDEgVHJhbnNpdGlvbmFs
aXB0LVR5cGUiIGNvbnRlbnQ9InRleHQvamF2YXNjcmlwdCIvPjxNRVRBIEhUVFAtRVFVSVY9Ikxv....[this goes on for a long time]

VEg9IjAiIEhFSUdIVD0iMTAwJSI+PC9URD48L1RSPjwvVEFCTEU+PC9ESVY+PC9ESVY+PC9ib2R5
PjwvaHRtbD4=

------=_NextPart_01C35DB7.4B204430--

 

I have tried several bodies, but the documentation is lacking for the formatSettings for Paginated Reports:

martijnkuiper_0-1741966165395.png

And with empty formatSettings and I also left the formatSettings completely out, but there is no difference. The response from the download action for this html file is as follows:

 

Failed to parse headers (url=https://api.powerbi.com:443/v1.0/myorg/groups/[REDACTED]/reports/[REDACTED]/exports/Mi9CbG9iSWRWMi1mYTJjOTY5Yy00NmZlLTRiYzktYjNkZS00NjFmZTE1YmExMTN3UHY3ZGxOLXlXVXpxU3N2THlGWk5YMlN2Yzl4MnRQeUJaWk4tQ2x0Lg==/file😞 [NoBoundaryInMultipartDefect()], unparsed data: '' Traceback (most recent call last): File "/home/trusted-service-user/cluster-env/trident_env/lib/python3.11/site-packages/urllib3/connection.py", line 464, in getresponse assert_header_parsing(httplib_response.msg) File "/home/trusted-service-user/cluster-env/trident_env/lib/python3.11/site-packages/urllib3/util/response.py", line 88, in assert_header_parsing raise HeaderParsingError(defects=defects, unparsed_data=unparsed_data) urllib3.exceptions.HeaderParsingError: [NoBoundaryInMultipartDefect()], unparsed data: ''

 

And the file itself remains unreadable base64 encoded and it seems to be partial. Now I have a hunch that there maybe is a formatSetting to get a UTF-8 / UTF-16 HTML file, but it also seems odd that that would have to be specified. How can I find out why my HTML file is not properly formatted as readable (and usable) HTML?

 

Adding just ?rdl:format=MHTML to a URL of a Paginated Report returns a readable HTML file. But when using the REST API, I cannot find why it keeps sending me base64 encoded partial files.

 

Thanks for helping me out

Martijn Kuiper


Viewing all articles
Browse latest Browse all 62213

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>