"Can an HTTP response in Traffic Parrot contain a binary file?" - software developer working for an e-commerce company.
Yes.
The simplest way to create a mock in Traffic Parrot that returns a binary file in the response is to create that mock by doing a recording. That assumes you have a real service that you can record.
If you don't have a real service that returns the binary file in the response, you can create a mapping manually. To do that:
- Create a file in trafficparrot-x.y.z/mappings directory called, for example mapping-dummy-file.json
- The mapping-dummy-file.json should contain the following (notice the reference to body-dummy-file.pdf):
{ "id" : "5d6a8f32-914c-4b67-ae15-f2c9d7b3e091", "name" : "mapping-dummy-file.json", "request" : { "url" : "/dummy.pdf", "method" : "GET" }, "response" : { "status" : 200, "bodyFileName" : "body-dummy-file.pdf", "headers" : { "Content-type" : "application/pdf" } } }
- Create the binary response body file body-dummy-file.pdf in trafficparrot-x.y.z/__files. You can use any PDF file just make sure the filename is specified in the mapping json file in bodyFileName attribute
- Now if you visit http://localhost:8081/dummy.pdf then a PDF binary file will be returned.