Apidog

All-in-one Collaborative API Development Platform

API Design

API Documentation

API Debugging

API Mock

API Automated Testing

Sign up for free
Home / Tutorials / Postman Tutorial: How to Loop Requests with Different Data?

Postman Tutorial: How to Loop Requests with Different Data?

Ever need to bombard your API with numerous test cases? Postman's loop functionality lets you automate repetitive requests, each with unique data sets. This excerpt unveils how to leverage loops for efficient API testing, saving you time and effort.

When testing APIs, it is often necessary to change parameter values and execute requests multiple times. So, how can you loop requests with different data sets in Postman? In this article, we'll introduce you to the methods for doing so.

💡
In Apidog, you can use the data set feature to more easily change parameter values and loop requests. With Apidog, you can create and manage test data through an intuitive UI, making it more flexible and convenient. Additionally, Apidog provides a comprehensive API solution, supporting the entire API lifecycle, including API design, documentation, test automation, and mock servers. It is a tool that can help improve API quality in general, not just API test automation.
Apidog An integrated platform for API design, debugging, development, mock, and testing
REAL API Design-first Development Platform. Design. Debug. Test. Document. Mock. Build APIs Faster & Together.
button

Why Loop Requests with Different Parameter Values?

When testing APIs, there are often situations where you need to change parameter values and execute requests multiple times or loop requests with different data sets. The reasons for this include:

  1. Validating Input Values
    APIs can receive various input values. By testing edge cases such as abnormal values and boundary values, you can verify the appropriate handling of API input values.
  2. Testing Different Use Cases
    APIs may support multiple use cases. By using different parameter values, you can test whether each use case is handled appropriately.
  3. Verifying Complex Conditions
    If the API processing logic is complex, a single parameter value may not be sufficient for testing. Changing the combination of parameters allows you to verify behavior under more complex conditions.
  4. Validating Response Validity
    Changing parameter values allows you to verify whether various responses (normal and abnormal) are returned appropriately from the API.
  5. Abnormal Testing
    By intentionally sending invalid parameter values, you can test whether the API's abnormal processing and error handling functions properly.
  6. Performance Testing
    By sending a large number of requests or large payloads, you can test the performance of the API.

In other words, API testing requires comprehensive verification of whether the API functions appropriately under various conditions by changing parameters, thereby improving API quality and reliability.

What is Postman?

Postman is a popular tool for API (Application Programming Interface) development and testing. With Postman, developers can create HTTP requests and send them to API endpoints, allowing them to test API behavior and inspect request and response data.

Postman

Postman also provides a feature-rich interface for creating and editing requests, managing headers, setting parameters, and inspecting responses.

初心者向け:Postmanの基本的な使い方を
Postmanは、APIテストなどを行うための定番のツールになります。API戦略を実施する場合は、Postmanを利用することで、その効率性を大幅に向上できます。そこで、本文では、基本的なPostmanの使い方を皆さんに紹介して、Postmanを全く使ったことがないユーザーでも、本文の内容を参照して、Postmanを使いこなすことができると思います。

How to Change Parameter Values and Loop Requests for Multiple Times in Postman

When testing APIs, you may want to execute the same request multiple times with different parameter values. How can you achieve this in Postman? Here's how:

Create Test Data

If you want to loop a request with different parameter values, you first need to create test data that includes all the parameter values. For example, as shown in the following image, create a JSON file called UserName.json and include five user names in this file.

Create Test Data

Use Variables in the Request

Next, use variables in the request. Here, the field names in the JSON data automatically become variable names, so you can use the test data in the request settings by referencing it as {{username}}.

Use Variables in the Request

Use Test Data in Collection Runner

Then, right-click on the collection containing this request and select "Run Collection" to execute the collection. In the collection runner screen, click "Data" -> "Select File" and import the JSON file you created earlier.

Select Test File

After importing the JSON data, you can click the "Preview" button to review the contents of the test data.

Preview Test Data

Run the Collection and Review the Results

If there are no issues with the test data, click the "Run XXXXXX" button below to execute the collection. When running the collection, you can review the execution results. In this case, since the GET request references the {{username}} variable, the result shows that all the field values from the test data are added one by one to the GET request, and the request is looped multiple times.

Run Collection and Review Results

So, if you want to change parameter values and loop requests multiple times in Postman, it's convenient to use Postman's test data feature.

Loop Requests More Conveniently with Apidog's Data Sets

If you want to execute requests with different parameter values more conveniently than Postman, Apidog is an excellent option. By using Apidog's data set feature, you can more easily change parameter values and loop requests.

button

Apidog provides a comprehensive API solution. You can freely use features like API design, documentation, test automation, and mock servers in Apidog. Here's how to change parameters and loop requests multiple times using Apidog's data set feature.

Step 1: Open Apidog and click "Automated Testing" from the right-side menu in your API project. You can create a test scenario and add test steps. You can reference saved APIs, and API Cases, or create new requests.

apidog create test scenario add api request

Step 2: Select "Test Data" from the top menu, and you can create data sets for testing through an intuitive UI, which is very convenient.

Step 3: After editing the test data, return to the automated testing screen and select the data set under "Test Data." Here, the number of iterations is automatically calculated based on the defined data set count.

apidog add test data
apidog add newly made test data

Step 4: Click on the request in the test step and define parameter values as variable names as needed.

apidog add params test scenario

Step 5: Run the test scenario. A "Select Test Data" window will also appear, allowing you to select the data set to use for this run. After selection, the parameter values will be automatically set in sequence, and the request will be looped and executed multiple times.

apidog select apidog set

Unlike Postman's collections, Apidog's test scenarios have no limitations, and you can add all APIs, API Cases, and custom requests as test steps. This feature allows for more flexible API test automation. Additionally, when using data sets for testing, Apidog allows you to either create test data through an intuitive UI or import existing files, providing a more convenient and flexible solution.

API Automation Testing using Postman
Dive into the world of API automation testing with Postman. Learn how to create your first API request and automate your tests. Start exploring Postman today!
button

Conclusion

On the other hand, Apidog's data set feature makes it easier to change parameter values and loop requests. With Apidog, you can create and manage test data through an intuitive UI, providing high flexibility and convenience. Additionally, Apidog provides a comprehensive API solution, supporting the entire API lifecycle, including API design, documentation, test automation, and mock servers. It is a tool that can help improve API quality in general, not just API test automation.

Looping requests by changing parameter values is an essential function in API testing. Postman and Apidog offer different methods to provide this functionality, allowing users to choose based on their needs.

The ability to change parameter values and loop requests is crucial for API testing. It enables input value validation, testing different use cases, verifying complex conditions, validating response validity, abnormal testing, and performance testing. Postman and Apidog each provide different methods to achieve this functionality, allowing users to choose the tool that best suits their needs.

Join Apidog's Newsletter

Subscribe to stay updated and receive the latest viewpoints anytime.