Data directives
You can use a data directive after a stress testing API to process its data, such as defining new data export parameters or transforming the output parameters of a preceding API. Subsequent stress testing APIs in the same serial link can then use this processed data. This topic describes how to add a data directive to transform an output parameter from a preceding API.
Background
You can add one or more data directives to a serial link. You cannot use data directives to process a global file parameter or a global custom parameter.
Consider a serial link that contains the following requests in order: Browse Product > Add to Cart > Make Payment. Both the Add to Cart and Make Payment requests (subsequent stress testing APIs) need to use the product ID from the Browse Product request (the preceding stress testing API). However, they require only the first four characters of the product ID as a parameter. Follow these steps.
Procedure
Log on to the PTS console. Add and configure the Browse Product, Add to Cart, and Make Payment APIs. For more information, see HTTP Node Overview.
In the Browse Product API, configure an output parameter. For more information, see API Output Parameters.
On the scenario configuration tab, click the drop-down arrow next to Add Directive and select Data Directive.
Click the
icon next to Data Directive. In the expanded section, edit the parameter name and parameter logic.In this example, to extract the first four characters of the product ID, you can use the function expression ${sys.substring("${ProductID}", 0, 4)}. In this expression, "${ProductID}" is the output parameter defined in the previous step.