Sending Binary Data with Postman and Newman

Tyler S picture Tyler S · Sep 19, 2016 · Viewed 18.3k times · Source

I am trying to create a collection that will upload images and be able to run it in multiple iterations and want to use newman to run it.

For our API it only supports uploading images through using binary data.

https://www.getpostman.com/docs/requests - Postman does not support saving the files for both form-data and binary.

https://www.getpostman.com/docs/run_file_post_requests - They show how you can upload images with Newman using form-data, but not for binary.

Is it possible to use newman with binary image upload?

Answer

ToAst picture ToAst · Mar 1, 2019

I used it like this which worked with the binary:

"body": {
    "mode": "file",
    "file": {
        "src": "path/to/your/file.jpg"
    }
}

That way you dont have to set the KEY, Type and so on. But you need to set it within the Header as

Content-Disposition: attachment; filename="file.jpg"

and in our case with

Content-Type: application/octet-stream