Im working on Rest Assured project and I want to get speciific part of response body but Im getting exception:
Exception in thread "main" java.lang.ClassCastException: class io.restassured.path.xml.XmlPath cannot be cast to class java.util.ArrayList (io.restassured.path.xml.XmlPath is in unnamed module of loader 'app'; java.util.ArrayList is in module java.base of loader 'bootstrap')
The code is taken from tutorial website so it should works correctly. Can anyone help?
public static void getSpecificPartOfResponseBody(){
ArrayList<String> amounts = when().get(url).then().extract().path("result.statements.AMOUNT") ;
int sumOfAll=0;
for(String a:amounts){
System.out.println("The amount value fetched is "+a);
sumOfAll=sumOfAll+Integer.valueOf(a);
}
System.out.println("The total amount is "+sumOfAll);
}
Aucun commentaire:
Enregistrer un commentaire