How to send a POST request with binary data as request body?

Is that jpeg confidential?

Are you ok with sending the jpeg to the Postman Echo service?

If you send the request as form data, it will return the base64 encoding.

For example…

image

image

You can parse the response using something similar to the following to just return the base64 encoded string,

let response = pm.response.json(); 

let base64 = response.files["dog.jpg"].split(",")[1];

console.log(base64)

If you want to send this is a pre-request script then it will be similar but you will need to use the pm.sendRequest() function.

1 Like