Extract a value from a REST Assured response
QuizEasy-MediumJava onlyAsked in: Capgemini, Coforge, Wipro
The login response is {"token": "abc123", "user": "admin"}. Which code stores the token in a variable?
- String token = given().body(creds).contentType(ContentType.JSON).when().post("/auth/login").then().statusCode(200).extract().path("token");
- String token = given().body(creds).post("/auth/login").token;
- String token = then().body("token");
- String token = given().body(creds).post("/auth/login").header("token");
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.