So, there is a REST API which is used to migrate some data in .zip format. The API answers the GET requests with the byte content of the requested file. I use Postman to perform the requests in order to automate the migration process.
I need to save the byte response without having to click on "send and download" since I need to send multiple requests and dynamically save all the files.
I made several attempts:
pm.collectionVariables.set('file', responseBody) and then POST it to a localserver which reads the data and saves it to a file. This results in an invalid zip file.btoa(), save the encoded string in a collection variable and then POST the base64 encoded string to a (python) localserver and decode it with base64.b64decode(data). Again, after writing the data to a file (in binary format, of course), this results in another invalid zip file.If I click "save and download" on the postman GUI I can successfully save the zip file which is valid. Hence the API surely answers with a valid binary content.
I know that Postman uses javascript and in my localserver I use python and the mix is sub-optimal, but base64 encoding is universal, right?
Additional info which might be useful: the API answers with Content-Type: "application/octet-stream; charset=UTF-8" and Content-Disposition: attachment; filename="webseal_config.zip"; filename*=UTF-8''webseal_config.zip. I don't really understand the practical consequences of the latter header, maybe the response not only contains the binary content but also the filename and I have to process the data in some way?