JSON Path Filter for specific transaction in VSM
search cancel

JSON Path Filter for specific transaction in VSM


Article ID: 132379


Updated On:


CA Application Test CA Continuous Application Insight (PathFinder)


When we use JSON Path filter in VSM, it applies for all transactions in the vsi. How to apply the filter for specific transaction in the VSM?
We see errors in logs if the variable $.parcelTrackingNumbers (in our case) is not part of request body for transaction other than we need the filter for. 
2019-05-02 18:33:16,204Z (14:33) [Send [VS_ABC_Run]/1] ERROR com.ca.lisa.apptest.json.FilterJSONGet - Invalid filter definition: Invalid path '$.lTrackingNumbers': json string can not be null or empty
java.lang.IllegalArgumentException: json string can not be null or empty
        at com.jayway.jsonpath.internal.Utils.notEmpty(Utils.java:259)
        at com.jayway.jsonpath.internal.JsonReader.parse(JsonReader.java:72)
        at com.ca.lisa.apptest.json.JSONUtil.getStringByJsonPath0(JSONUtil.java:518)
        at com.ca.lisa.apptest.json.JSONUtil.getStringByJsonPath(JSONUtil.java:476)
        at com.ca.lisa.apptest.json.JSONUtil.getByJsonPath(JSONUtil.java:548)
        at com.ca.lisa.apptest.json.FilterJSONGet.subPostFilter(FilterJSONGet.java:129)
        at com.itko.lisa.test.FilterBaseImpl.subFilter(FilterBaseImpl.java:148)
        at com.itko.lisa.test.FilterBaseImpl.postFilter(FilterBaseImpl.java:126)
        at com.itko.lisa.test.TestNode.doFilters(TestNode.java:1482)
        at com.itko.lisa.test.TestNode.doPostFilters(TestNode.java:1439)
        at com.itko.lisa.test.TestNode.executeNode(TestNode.java:995)
        at com.itko.lisa.test.TestCase.execute(TestCase.java:1294)
        at com.itko.lisa.test.TestCase.execute(TestCase.java:1198)
        at com.itko.lisa.test.TestCase.executeNextNode(TestCase.java:1183)
        at com.itko.lisa.test.TestCase.executeTest(TestCase.java:1124)
        at com.itko.lisa.coordinator.Instance.run(Instance.java:204)


All supported environments.  




This is the expected behavior.  The Json Xpath filter will be applied to all the transactions that hit the VS listener step and it will validate that filter.  This filter is intended for a TEST step.  

To avoid this error,  you could do the following.  

1. Create a Java Script step, and look for that particular URL or Operation Name(). 

import com.itko.util.ParameterList; 

>// Manipulate operation 
String operation = lisa_vse_request.getOperation(); 

2, Then add the Xpath filter on the JS step if it finds that Operation.. 

This way we are only adding the filter for that particular Operation.