Get binary response body from pm.sendRequest and base64 encode

Is there a way to get the binary response body from pm.sendRequest? On https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/#scripting-with-response-data I see a pm.response.text() which returns a String, (which might be a “binary” String as seems to be common in Javascript).

I’m asking because I’m downloading a PDF file in my Pre-request script and base64 encoding the response.text() with btoa() but the result is too short so somewhere the data seems to be truncated.

Is there anywhere to report actual bugs for Postman? I’m sure I can reproduce this in a small collection, perhaps someone could fix it then.

Thanks,
Frans

2 Likes