API with JSON body
Introduction
The JSON Body feature in scriptless automation provides a simplified way to handle complex JSON structures by referencing external JSON files or using dynamic JSON values. This functionality allows for cleaner CSV files and more manageable automation scripts.
Using the JSON Body Feature
There are two primary ways to utilize the JSON Body feature:
1. Direct Use of JSON File
Users can create a JSON file and store it in the specified directory, then reference it within their CSV template. This method is ideal for static JSON payloads that do not change frequently.
File Directory
Syntax for CSV Template
Example
JSON File
2. Using Dynamic JSON Value
For scenarios requiring dynamic JSON values, users can define a JSON schema and specify placeholders that can be replaced with actual values in the CSV file.
JSON Schema Example
CSV Template with Dynamic JSON Value
In this approach, the placeholder {{name}}
in the JSON file will be replaced with the value PrecisionTestAutomation
specified in the BODY:VALUE
field.
Advantages of JSON Body Feature
Maintainability: Separating the JSON body from the CSV file reduces clutter and makes the automation scripts easier to maintain.
Scalability: Managing JSON structures becomes more scalable as changes to the JSON do not require modifications to the CSV template.
Flexibility: Supports both static and dynamic JSON payloads, allowing for a wide range of testing scenarios.
Conclusion
The JSON Body feature enhances scriptless automation by offering an efficient way to manage JSON payloads. By enabling the direct use of JSON files or dynamic JSON values, it allows for a more organized approach to API testing with complex JSON structures. This feature streamlines the process of configuring API requests, especially for those that require large or frequently changing JSON bodies.
Last updated
Was this helpful?