Rest Rules

Transformer module's Rules feature offers a powerful way to dynamically modify responses to meet specific conditions, improving the precision and flexibility of API testing scenarios.

Here, User can see two tabs. First one is Request Rules & the second is Response Rules.

Request Rules : Request rules scripts are used to update the L3 request body based on the L1 request body. Response Rules : Response rules scripts are used to update the L1 response body based on the L3 response body.

let's see how these two rules tabs are used to dynamically modify the responses.

Example : We will use the same example of Withdrawal from previous section to apply rules.

//  Request Rules
     if(l1.get('transaction_type') == 'withdrawal'){
        l3.set('9','6011');
    }

//  Response Rules
    l1.set('card_number',l3.get('2'));

Now test this request in API module and get dynamically modified response.

//Expected Response after Rules apply
{
    "transaction_id": "123456",
    "status": "success",
    "card_number": "1234567890123456789"
}

To know how data flow of these requests checkout Transformer's Analytics submenu.