4

I am using the Postman Collection Runner to automate a series of API calls. On one of these API calls I need to submit a binary file as the body of a POST. When setting up the Collection Runner I see how to select a file, but I can't figure out how to attach that file to the body of the POST request in the "Pre-request Script".

Is it possible in a "Pre-request Script" to load a binary file into the "data" object?

karel
  • 5,489
  • 46
  • 45
  • 50
Pete Blatner
  • 41
  • 1
  • 2
  • hi, in your request's body, before using the runner, did you select the "binary" radiobutton ? – A.Joly Aug 22 '17 at 08:57
  • Yes. I can manually initiate a POST call using Postman, submitting a binary file just fine. What I am trying to do is execute that same API via the Collection Runner, loading a binary file into the request in a "Pre-request Script". – Pete Blatner Aug 22 '17 at 13:53
  • well, I'm also a beginner in pre-requests scripting. I'm not sure you can do something like this as postman runner provides the possibility to select the file. Did you have a look to loadash functions ? maybe one of them would allow you to load the binary file in a global variable ? or you may use javascript function to load your file into a global variable ? (sorry I'm also a beginner in javascript ...) – A.Joly Aug 23 '17 at 07:00

1 Answers1

1

Currently postman collection runner doesn't support file uploads. You will have to use newman to execute your Automation Test Suite(collection).

Have a look at this answer: Postman - POST request with file upload

Anant Naugai
  • 538
  • 4
  • 14