Passing API Path Parameters Dynamically
This document outlines a use case demonstrating how to dynamically pass path parameters in API calls. This functionality allows users to create flexible and reusable API tests where parameter values are determined at runtime, enhancing test automation capabilities.
The below example illustrates how to dynamically pass a product ID in the API path to retrieve product details.
 
 
- 
Step 1: Define a constant value_1with a new title for the product. This will be used in the product creation and verification steps.1. value_1 = Get constant value new title for the prodyctd
- 
Step 2: Call the FakeStoreAPI > CreateProductendpoint with thevalue_1as the product name. Store the API response inapiResponse_1.2. apiResponse_1 Call API FakeStoreAPI > CreateProduct ( name : value_1 )
- 
Step 3: Verify that the HTTP response status code of apiResponse_1is 201 (Created).3. Verify status code of http response apiResponse_1 == 201
- 
Step 4: Extract the JSON body from apiResponse_1and store it injson_3. This JSON contains the dynamically generatedidof the newly created product.4. json_3 = Get Json body of http response apiResponse_1
- 
Step 5: Call the FakeStoreAPI > GetProductDetailsByIDendpoint, passing theidfromjson_3as a dynamic path parameter. Store the API response inapiResponse_4.5. apiResponse_4 Call API FakeStoreAPI > GetProductDetailsByID ( id : ( json_3.id ) )Note: The syntax (json_3.id)represents the dynamic parameter injection.
- 
Step 6: Verify that the HTTP response status code of apiResponse_4is 200 (OK).6. Verify status code of http response apiResponse_4 == 200
- 
Step 7: Extract the JSON body from apiResponse_4and store it injson_6.7. json_6 = Get Json body of http response apiResponse_4
- 
Step 8: Verify that the titlefield injson_6matches thevalue_1constant.8. Verify text $(json_6.title) equals value_1