public interface Response extends ResponseBody<Response>, ResponseOptions<Response>
Usage example:
Response response = get("/lotto");
String body = response.getBody().asString();
String headerValue = response.getHeader("headerName");
String cookieValue = response.getCookie("cookieName");
You can also map the response body to a Java object automatically. REST Assured will use Jackson, Gson and JAXB to accommodate this:
Message message = get("/message").as(Message.class);
| Modifier and Type | Method and Description |
|---|---|
ValidatableResponse |
then()
Returns a validatable response that's lets you validate the response.
|
peek, prettyPeek, prettyPrint, printas, as, as, htmlPath, jsonPath, jsonPath, path, xmlPath, xmlPath, xmlPathasByteArray, asInputStream, asStringandReturn, body, contentType, cookie, cookies, detailedCookie, detailedCookies, getBody, getContentType, getCookie, getCookies, getDetailedCookie, getDetailedCookies, getHeader, getHeaders, getSessionId, getStatusCode, getStatusLine, header, headers, sessionId, statusCode, statusLine, thenReturnValidatableResponse then()
given().
param("firstName", "John").
param("lastName", "Doe").
when().
get("/greet").
then().
body("greeting", equalTo("John Doe"));
Copyright © 2010–2014. All rights reserved.