2

How can I attach a file to the environment in order to launch the collection in the Postman collection runner? The file is attached to the form-data, and manually the request runs ok, but as soon as I run it in the collection runner, the runner doesn't see the file and the 500 Internal server error occurs. How can this issue be fixed?

Michael 12345
  • 85
  • 2
  • 5
  • Can you clarify the question please? Attaching a file to the collection runner in the same way that you attach file to individual requests is not the same and will not work. – Danny Dainton Apr 03 '18 at 15:38
  • If some requests have to send files (for instance, upload an image etc.), we can attach a file to the request via the form-data, and we need to choose the file manually each time we launch Postman, as far as I can see, and the file can't be seen if we launch the collection runner, so the upload tests fail. I managed to "attach the file tightly" using Newman and modifying the JSON-file of the collection, specifying the image source there. My point was - is it possible to make such tests run with Postman collection runner without such kind of tricks? – Michael 12345 Apr 04 '18 at 08:16
  • I don't believe that you can do this through the UI and Newman is the only (might be wrong) that you can achieve this to run the collection. – Danny Dainton Apr 04 '18 at 08:42

1 Answers1

2

Request BodySee the full detail in the link While constructing requests, you’ll work frequently with the request body editor. Postman lets you send almost any kind of HTTP request. The body editor is divided into 4 areas and has different controls, depending on the body type.

Note about Headers: When you are sending requests through the HTTP protocol, your server might expect a Content-Type header. The Content-Type header allows the server to parse the body properly. For form-data and urlencoded body types, Postman automatically attaches the correct Content-Type header so you don’t have to set it. The raw mode header is set when you select the formatting type. If you manually use a Content-Type header, that value takes precedence over what Postman sets. Postman does not set any header type for the binary body type.

Form-data form-data

multipart/form-data is the default encoding a web form uses to transfer data. This simulates filling a form on a website, and submitting it. The form-data editor lets you set key-value pairs (using the data editor for your data. You can attach files to a key as well. Note: due to restrictions of the HTML 5 spec, files are not stored in history or collections. You will need to select the file again the next time you send the request.

Uploading multiple files each with their own Content-Type is not supported yet.See the image here in the link

  • "Note: due to restrictions of the HTML 5 spec, files are not stored in history or collections." - so, this means that I cannot attach a file, and this request can only be checked manually? – Michael 12345 Apr 03 '18 at 09:05