Back to Cheat SheetsAPI · Intermediate
REST Assured cheat sheet
Given/when/then syntax, extraction and schema validation in Java.
Basic request
GET + assert
given().baseUri(url)
.when().get("/users/1")
.then().statusCode(200).body("name", equalTo("QA"));POST body
given().contentType(JSON).body(payload).post("/users")Auth
given().auth().oauth2(token)Extraction and validation
Extract value
String id = resp.jsonPath().getString("id");Schema
.body(matchesJsonSchemaInClasspath("user.json"))Spec reuse
RequestSpecification spec = new RequestSpecBuilder()...build();Go beyond the reference
Book a free demo class and apply these commands on live project work.