Posted: 18 Jun 2019 10:46 EDT Last activity: 18 Jun 2019 10:46 EDT
How to decode a Zip file from a REST GET response
My application has to call an external REST service with Basic Authentication in order to retrieve and download a zip file (byte array) containing a set of files. The response is a simple byte array, not a json. The goal is to provide to the user a button to download that specific file. Since the service is available only on client specific network and only Pega has the access, first the zip file has to be downloaded in Pega and then to be made available to the final user.
I created a simple REST connector and mapped the response on a property of Text Type giving me the byte array as raw string. When I call the connector from a data page the response is displayed as it's shown in the attachment. If I tried to map the response on a Java Object of class java.io.ByteArrayOutputStream but I don’t receive anything in this case.
What is the best way to map the response?
How the response can be manipulated/decoded in Pega and make it available when the user click on a the button?