Need help in findAll method in json path | Rest Assured Forum
N
Nagarro Posted on 15/04/2022

Hi,

 

i am trying below code but it is giving me all API list. need some help here

 

//find All
@Test
public void test6()
{
RestAssured.baseURI = "https://api.publicapis.org";
RestAssured.basePath="/entries";
Response response = null;
try {
List<HashMap<String, Object>> lst2= given().get().then().extract().path("entries.findAll{it.API='Cat Facts'}");
System.out.println("detailsOfAdoptAPetAPI :" + lst2);
} catch (Exception e) {
e.printStackTrace();
}
}




result:
detailsOfAdoptAPetAPI :[{Description=Resource to help get pets adopted, Category=Animals, HTTPS=true, Auth=apiKey, API=Cat Facts, Cors=yes, Link=https://www.adoptapet.com/public/apis/pet_list.html}, {Description=Collection of axolotl pictures and facts, Category=Animals, HTTPS=true, Auth=, API=Cat Facts, Cors=no, Link=https://theaxolotlapi.netlify.app/}, {Description=Daily cat facts, Category=Animals, HTTPS=true, Auth=, API=Cat Facts, Cors=no, Link=https://alexwohlbruck.github.io/cat-facts/}, {Description=Cat as a service (cats pictures and gifs), Category=Animals, HTTPS=true, Auth=, API=Cat Facts, Cors=no, Link=https://cataas.com/}, {Description=Pictures of cats from Tumblr, Category=Animals, HTTPS=true, Auth=apiKey, API=Cat Facts, Cors=no, Link=https://docs.thecatapi