How to send multiple form data with each form has an file attached in postman request

Viewed 34

There is one API which accepts data in below format, I want to test this API through postman but not sure how to send data in below format in Postman. I tried multiple things in postman but API is not accepting request.

[
  {
    "firstName":"",
    "age":1,
    "image":"This should be actual image"
  },
  {
    "firstName":"",
    "age":1,
    "image":"This should be actual image"
  },
  {
    "firstName":"",
    "age":1,
    "image":"This should be actual image"
  }
]
1 Answers
[
  {
    "firstName":"",
    "age":1,
    "image":"This should be actual image"
  },
  {
    "firstName":"",
    "age":1,
    "image":"This should be actual image"
  },
  {
    "firstName":"",
    "age":1,
    "image":"This should be actual image"
  }
]

For above type of request we should send data in below format

In Postman -> Body -> "form-data"

You will find Key-Value columns. Don't give any key and paste above json inside "Value" column first row. Don't give any key. Remove key from above json on which we are supposed to have file.

[
  {
    "firstName":"",
    "age":1
  },
  {
    "firstName":"",
    "age":1
  },
  {
    "firstName":"",
    "age":1
  }
]

enter image description here

In Key column and second row you will have invisible drop down with options "Text", "File". Select "File". In "Value" column 2nd row you will see "Select files" button. Click on that and select the single/multiple files. enter image description here

This we would be able to send multiple form data with a file in each form.

Related