REST Assured interview questions — Medium
310 medium-level REST Assured questions from our API Testing bank, each with the correct answer and an explanation of why it is correct.
What this covers
REST Assured appears throughout API Testing interviews. At medium level, interviewers are typically checking that you have used it in practice: what you configured, what broke, and how you knew it worked. Work through these, then explain your answer out loud; the second part is what interviews actually test.
20 example questions
1. In REST Assured, how do you assert a JSON field like data.id equals 5 in the body?
- A. Body("data.id", equalTo(5)) using a Hamcrest matcher.correct
- B. AssertEquals(5).
- C. Then().json(5).
- D. Expect(5).
Why: REST Assured uses JsonPath expressions with Hamcrest matchers, e.g. .body("data.id", equalTo(5)).
2. In a CI/CD pipeline review, consider this: How do you assert data.id == 5 in a REST Assured body?
- A. Body("data.id", equalTo(5)).correct
- B. AssertEquals(5).
- C. Expect(5).
- D. Then().json(5).
Why: REST Assured uses JsonPath with Hamcrest matchers.
3. "Sets or asserts the JSON content type" — in REST Assured, this describes which of the following?
- A. ResponseSpecification.
- B. QueryParam.
- C. ContentType(ContentType.JSON).correct
- D. Given().
Why: contentType(ContentType.JSON): Sets or asserts the JSON content type.
4. "Begins validation of the received response" — in REST Assured, this describes which of the following?
- A. RelaxedHTTPSValidation().
- B. Then().statusCode(200).correct
- C. QueryParam.
- D. ResponseSpecification.
Why: then().statusCode(200): Begins validation of the received response.
5. "Disables SSL certificate validation for test environments" — in REST Assured, this describes which of the following?
- A. Given().
- B. PathParam.
- C. Then().statusCode(200).
- D. RelaxedHTTPSValidation().correct
Why: relaxedHTTPSValidation(): Disables SSL certificate validation for test environments.
6. On a release readiness call: extract().path("token") is used to:
- A. Send a request.
- B. Assert time.
- C. Pull a value from the response for reuse.correct
- D. Log headers.
Why: extract() pulls values (JsonPath) to reuse, e.g. an auth token.
7. "Sends the HTTP request to the endpoint" — in REST Assured, this describes which of the following?
- A. RelaxedHTTPSValidation().
- B. PathParam.
- C. QueryParam.
- D. When().get("/users").correct
Why: when().get("/users"): Sends the HTTP request to the endpoint.
8. REST Assured tests are typically structured with which readable BDD-style syntax?
- A. Arrange/act/assert keywords only.
- B. Given() / when() / then().correct
- C. Setup() / run() / verify().
- D. Open() / send() / close().
Why: REST Assured uses a BDD-style given() (setup: headers, params, body), when() (the request), then() (assertions).
9. "Starts request specification: params, headers, body, auth" — in REST Assured, this describes which of the following?
- A. ContentType(ContentType.JSON).
- B. QueryParam.
- C. RelaxedHTTPSValidation().
- D. Given().correct
Why: given(): Starts request specification: params, headers, body, auth.
10. Which of the following statements about REST Assured is TRUE?
- A. REST Assured has no support for OAuth2 authentication.
- B. JSON Schema validation is supported via the json-schema-validator module.correct
- C. REST Assured cannot validate nested JSON fields.
- D. REST Assured is a JavaScript library for browser testing.
Why: matchesJsonSchemaInClasspath validates structure, not just values.
11. "Sets a named path parameter in the URL template" — in REST Assured, this describes which of the following?
- A. PathParam.correct
- B. ContentType(ContentType.JSON).
- C. QueryParam.
- D. RelaxedHTTPSValidation().
Why: pathParam: Sets a named path parameter in the URL template.
12. Identify the accurate statement about REST Assured:
- A. REST Assured is a JavaScript library for browser testing.
- B. REST Assured has no support for OAuth2 authentication.
- C. REST Assured cannot validate nested JSON fields.
- D. REST Assured supports logging of requests and responses for debugging with log().all().correct
Why: Conditional logging like log().ifValidationFails() keeps output clean.
13. "Adds a query string parameter to the request" — in REST Assured, this describes which of the following?
- A. Given().
- B. When().get("/users").
- C. QueryParam.correct
- D. ContentType(ContentType.JSON).
Why: queryParam: Adds a query string parameter to the request.
14. In a CI/CD pipeline review, consider this: REST Assured tests use which readable style?
- A. Arrange/act/assert.
- B. Given()/when()/then().correct
- C. Setup/run/verify.
- D. Open/send/close.
Why: REST Assured uses BDD-style given/when/then.
15. Which statement correctly describes REST Assured?
- A. REST Assured is a JavaScript library for browser testing.
- B. RequestSpecification must be redefined inside every single test.
- C. Extract().path() pulls values from a response for use in subsequent requests.correct
- D. REST Assured cannot validate nested JSON fields.
Why: Extraction supports chaining dependent API calls.
16. In REST Assured, which of the following is described as: "Starts request specification: params, headers, body, auth"?
- A. Given().correct
- B. Then().statusCode(200).
- C. PathParam.
- D. RelaxedHTTPSValidation().
Why: given(): Starts request specification: params, headers, body, auth.
17. In REST Assured, which of the following is described as: "Sends the HTTP request to the endpoint"?
- A. When().get("/users").correct
- B. QueryParam.
- C. ResponseSpecification.
- D. Then().statusCode(200).
Why: when().get("/users"): Sends the HTTP request to the endpoint.
18. Which REST Assured concept matches this description: "Sets or asserts the JSON content type"?
- A. PathParam.
- B. ContentType(ContentType.JSON).correct
- C. QueryParam.
- D. Then().statusCode(200).
Why: contentType(ContentType.JSON): Sets or asserts the JSON content type.
19. In the context of REST Assured, which of the following is a correct statement?
- A. JSON Schema validation is supported via the json-schema-validator module.correct
- B. RequestSpecification must be redefined inside every single test.
- C. Response values cannot be extracted for use in later requests.
- D. REST Assured is a JavaScript library for browser testing.
Why: matchesJsonSchemaInClasspath validates structure, not just values.
20. Which REST Assured concept matches this description: "Sends the HTTP request to the endpoint"?
- A. Then().statusCode(200).
- B. When().get("/users").correct
- C. PathParam.
- D. Given().
Why: when().get("/users"): Sends the HTTP request to the endpoint.