Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Trying to return a binary tar file as the response.content

Our objective is to hit an endpoint to download a tar.gz to disk with pre-determined filename. The catch we have is trying to decode the binary string into a valid archive. We've tried a Python policy (base64decode) as well as @Dino-at-Google's online sample, but we are missing something. When done within Apigee, decoding the text will not be a valid archive. In Dino's POC we can decode our string but need to open the response file, remove the top 5-6 lines including headers, date/time and response code then save with tar.gz extension and it is a valid archive. We've tried removing headers using Dino's included Assign Message policy however it doesn't work for all headers. I have included a sample json we get from the backend ("binary" is the base64-encoded tar.gz and filename). Thank you! binarylog.txt (download and change extension to json)

Solved Solved
0 4 1,382
1 ACCEPTED SOLUTION

ok I understand

Just looking at your curl command, you are using -i, which tells curl to ... emit the headers it receives in response. Are those the 5 lines you are removing?

If that's the case, then you may be able to avoid the problem by omitting the -i from the curl command line. Can you try that and let me know?

View solution in original post

4 REPLIES 4