How to run multiple API request with multiple testdata for each request via Newman

I want to run multiple APIs in one collection with multiple request data(query parameter/body)
I want to do all this via a single newman command

Can i achieve this usecase?

Or can you suggest a different solution with minimum changes to above setup?

1 Like

Hi @pmaindan,

Welcome to the Postman community ! Correct me If I am wrong, are you talking about sending requests with request body to API endpoints(not belonging to a single API) in one collection. If that is accurate, then the answer is Yes, it does not matter how many API endpoints you are using, you can run a single collection using the Newman CLI tool, relevant documentation can be found here:
https://learning.getpostman.com/docs/postman/collection_runs/command_line_integration_with_newman/

I would suggest you try to use folders with appropriate names in the collection so you can create a separation between the different API’s for your reference.

Thanks for the material @aamir.ahmed, but can we identify which request data in the array of json input will serve which api request in the collection

Do u imply that we need to execute different/multiple newman cmds like
–> newman run -folder api1 -data inputfile1
–> newman run -folder api2 -data inputfile2

Doing this in an automation fashion requires to maintain a mapping file between api folders and inputfiles

Do we have the ability to make this possible in just one command?

Hi @pmaindan,

If you wish to use data files in your newman run, you would have to execute the following command for each folder if you wish to organize your folders into requests to different API:
newman run --folder -d

I am not sure what you mean by a mapping file, but you can get the entire list of usage options for newman using the following command:
newman run -h

If by any chance you are using a CI/CD pipeline you could probably create a Makefile and enter the multiple newman run commands for each folder there. Hope that helps.

1 Like

Hi , I can’t open the material