cancel
Showing results for 
Search instead for 
Did you mean: 

Static images in HTML Export

craig_wilson2
Explorer
0 Kudos

I must be missing something.  For charts in Webi Reports, I can't understand why exporting a Webi Report to HTML would generate a link back to the server with a ticking time bomb logon token attached for the chart URL?  Is there some way to have the HTML export contain static normal images of charts, like jpeg or png?

Accepted Solutions (1)

Accepted Solutions (1)

eric_festinger
Contributor
0 Kudos

hi Craig,

The reason is: as you ask for "text/html", only the HTML part may be returned. And thus the only way to provide the images is through links.

However, may I suggest you export the report, accepting "application/zip" ?

Regards,

eric

craig_wilson2
Explorer
0 Kudos

Thanks for the suggestion.  I tried this.  It generated a file.  If I give the file a .zip extension, it won't open (says it is invalid).   If I give it a .html extension, it won't open.  What extension is it supposed to have?

eric_festinger
Contributor
0 Kudos

It should actually be a real ZIP file...

Can you copy paste the call you do?

eric

craig_wilson2
Explorer
0 Kudos

From Powershell:

$RequestUri         = $environment + "/biprws/raylight/v1/documents/" + $DocID + "/reports/1"           

#$RequestHeaders     = @{"Accept" = "text/html";"Content-Type" = "application/json";"X-SAP-LogonToken" = $LogonToken}           

$RequestHeaders     = @{"Accept" = "application/zip";"Content-Type" = "application/json";"X-SAP-LogonToken" = $LogonToken}           

$HTML = Invoke-RestMethod -Method GET -Uri $RequestUri -Headers $RequestHeaders

$HTML | Out-File ("d:/temp/report.zip")  

daniel_paulsen
Active Contributor
0 Kudos

Hi Craig,

My guess is that your zip file is being downloaded as text rather than a binary, so the encoding is not right.  you might need to do something along the lines of:

$HTML | Out-File ("d:/temp/report.zip")  -encoding "UTF8"


Dan

craig_wilson2
Explorer
0 Kudos

Thanks for all the quick responses on this forum! 

2 things needed to be done.

1. Specify charset (encoding) as Dan mentioned.  The correct syntax for doing that is below.

2. Avoid use of Powershell variable.  It turns out Powershell is trying to parse the results if the result of the rest call is stored in a variable, and it corrupts the result.  To avoid this, you take the result of the REST call directly to a file with an -OutFile parameter

$RequestHeaders     = @{"Accept" = "application/zip;charset=utf-8";"Content-Type" = "application/json";"X-SAP-LogonToken" = $LogonToken}           

Invoke-RestMethod -Method GET -Uri $RequestUri -Headers $RequestHeaders -OutFile "d:/temp/report.zip"

So it works great!  Thanks Eric and Dan!

There are even some Powershell methods to extract the zip file if need be.  I may also implement that.  If so, I'll update this post with my code.

eric_festinger
Contributor
0 Kudos

Great, Craig! ... and thanks for sharing the way you solved it

Answers (0)