Is it possible to send an image file in the pre-request script of a request

Hello everyone!

To give context to my problem, I have a set of endpoints that are for posting, deleting and getting images. The post requests use the binary option in the Body section of the request.

I was wondering if it was possible to set the body to use the binary body option in the pm.sendRequest() function to send image data?

url: ‘Some URL’,
method: ‘POST’,
header: {
body: {
mode: ‘binary’, (Is this possible?)
data: {{binary data here}} (Is this possible?)
}, function(err, res) {
{{do stuff here}}

if this is possible, please let me know.

Try something like this:

    url: '',
    method: 'POST',
    body: 'data:image/png;base64,iVBORw0KGgoAAAANS[...]==', 
function(err, res) {


Thank you, that clears that part up. I have a follow up question, I was wondering if it was possible to retrieve file data from your local machine and convert it to base64, or capture the binary data from a GET request to an image URL and convert it to base64 in order to POST it on a request?

I guess not, as you cannot read files when using scripts. Of course, this could be possible in Newman with some custom scripting.

You can’t access your local file system directly for security reasons. However, as a workaround, you could set up a local server to listen for requests sent from Postman, and then access your local file system in that way.

Here’s an example of how to write to your file system - reading from your file system would be a similar process: