Home > Enterprise >  How can I insert variable in rest assured filter instead of hardcoding?
How can I insert variable in rest assured filter instead of hardcoding?

Time:10-25

Hi I have the following example rest assured filter written in java:

String amountSold = jsonPath.getString("book.find{it.release == '2020-09-22'}.AmountSold");

How can I replace this filter to include a variable instead of hardcoding '2020-09-22'?

CodePudding user response:

String amountSold = jsonPath
    .param("rdate", '2020-09-22')
    .getString("book.find{it.release == rdate}.AmountSold")

https://www.javadoc.io/doc/io.rest-assured/json-path/3.0.0/io/restassured/path/json/JsonPath.html#param-java.lang.String-java.lang.Object-

  • Related