How to Send multiple request concurrently/Sequentially in postman with different set of values for each request?

只谈情不闲聊 提交于 2021-02-07 09:39:37

问题


For example, below is the JSON request data to "add a device" in the DB. For example, I want to add 10000 devices with different IMEI number and different phone number to the server for testing purpose. So, how to send the request at once. I'm ready to create 10000 devices data with different values manually. Now I can able to send one by one only.But how to send all the request at once?

{ "device_name":"34793812453274392", "imei_num":"36xxxxxxxxxxxx5", "phone_num":"8666606451", "device_city":"Chennai", "device_state":"Tamil Nadu", }

As I'm new to POSTMAN, required detailed info. Thanks in advance.


回答1:


The thing that should work is :

  • you prepare your input JSon body with variables. ie, from your example :

{ "device_name":{{device_name}}, "imei_num":{{imei_num}}, "phone_num":{{phone_num}}, "device_city":{{device_city}}, "device_state":{{device_state}}, } the {{}} is for variables

  • You create a CSV file with the corresponding headers (one for each variable of your input JSON) and all the values you need:

example:

line 1 : device_name, imei_num, phone_num, device_city, device_state
line 2 : "34793812453274392", "36xxxxxxxxxxxx5", "8666606451", "Chennai", "Tamil Nadu"
... and so on ...
line 10000 :  ... 

Then, in the Postman runner (see here ), you select the data file (Data / Select file) with CSV type (you should have an option to check the content, but be careful as you'll have a lots of rows, it may take a long time, I suggest you try first with a small CSV file)

You just set ONE iteration (otherwise you'll play x times 10000 requests). It will parse your file and, for each data line, it will send your request with replacing the body's variables by the corresponding data associated to the corresponding header. Header names must have the same label as your variables.

Launching the runner will launch your 10000 requests sequentially

If you prefer, you can use JSON input file as data file, see here

Don't hesitate to have a look at postman documentation, it's pretty complete.




回答2:


Put all the data into a JSON Array and then do them all as one post. Currently you only have one set of data you're posting in.

Just create a json body with all the data you need to enter and post them into the same API endpoint.




回答3:


There is an option called Runner at the top left corner of your Postman application. You can select the collection you need to run with number of iterations and delay time between each request. But the thing is you cannot alter the values inside the JSON request. Thanks



来源:https://stackoverflow.com/questions/47460417/how-to-send-multiple-request-concurrently-sequentially-in-postman-with-different

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!