How to pass response image to second request's form-data

Consider following situation,

  • In collection run (chaining requests), I want to run two requests sequentially.
  • First request receives image blob as a response
  • Second request need to use first request’s response (image blob) as form-data’s input as a file
  • In separate (detached) tests, it work perfectly while I download first request’s response as image file and then use that local image as second request’s form-data file field.
  • Now I want to automate this using Pre-request Script or Tests script

What I did so far,

  • In the first request’s Tests I used following javascript code to save image response as variable named imageData
let outputImage = pm.response.dataURI();
pm.variables.set('imageData', outputImage);
  • In second request I set up input form-data like so,
    image

but when I run collection run, second request always fails…

In detached situation, I usually use like following and works well.
image

So question is how do I send (link) first request’s output image to second request’s input form-data?

Not sure you can save a binary image to a variable like that.

I don’t have any examples with images to test this, but you might need to encode and decode the image.

Hopefully someone with more experience of working with images in Postman will be able to provide more details or an example.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.