How to Use This Guide

These are the REST Assured interview questions that Automation Testers and SDETs encounter most frequently during interviews.

Each answer provides a concise explanation suitable for interview revision. For complete explanations, code examples, and practical demonstrations, refer to the linked tutorial.

For the complete learning path, begin with the Complete REST Assured Guide.

Advertisement

Fundamentals (Q1–5)

Q1. What is REST Assured?

REST Assured is a Java library used for automating REST API testing.

It is widely used to build API automation frameworks with Maven and TestNG.

Learn more: REST Assured Fundamentals


Q2. Why is REST Assured used?

REST Assured provides:

Learn more: REST Assured Fundamentals


Q3. What is a RESTful Web Service?

A RESTful web service follows REST architectural principles such as:

  • Stateless communication
  • Client-Server architecture
  • Uniform Interface
  • Cacheable responses
  • Layered architecture

Learn more: REST Assured Fundamentals


Q4. What is the difference between REST and SOAP?

  • REST is a lightweight architectural style that commonly exchanges JSON data.
  • SOAP is a strict XML-based protocol.

Learn more: REST vs SOAP


Q5. When should you use REST Assured instead of Postman?

  • Postman is ideal for manual and exploratory API testing.
  • REST Assured is preferred for scalable code-based API automation frameworks.

Learn more: REST Assured vs Postman


Setup & Syntax (Q6–9)

Q6. What Maven dependency is required for REST Assured?

Add the rest-assured dependency to the pom.xml file along with supporting libraries such as json-path, xml-path, and a testing framework like TestNG.

Learn more: Setup & Syntax


Q7. What do given(), when(), and then() represent?

REST Assured follows BDD syntax:

  • given() – Request setup
  • when() – Execute the request
  • then() – Validate the response

Learn more: Setup & Syntax


Q8. How do you send GET, POST, PUT, PATCH, and DELETE requests?

The HTTP method is chained after when().

For example:

.when().post("/users")

Learn more: Sending Requests


Q9. How do you pass query parameters, path parameters, headers, and cookies?

Within given() using:

  • .queryParam()
  • .pathParam()
  • .header()
  • .cookie()

Learn more: Sending Requests


Validation & Extraction (Q10–15)

Q10. How do you validate an API response body?

Response validation is performed inside then() using Hamcrest matchers.

Example:

.body("field", equalTo(value))

Learn more: Response Validation


Q11. What is JsonPath?

JsonPath is a query syntax used to navigate and extract values from JSON responses.

Values can be extracted using JsonPath or .extract().path().

Learn more: Logging & Extraction


Q12. How do you validate API response time?

Validate the response time inside then() and compare it against the application's SLA.

Learn more: Response Validation


Q13. How do you validate nested JSON objects and arrays?

Use JsonPath expressions together with matchers such as hasSize() to validate nested objects and arrays.

Learn more: Advanced Validation


Q14. How do you log requests and responses?

Use:

  • .log().all() to log everything.
  • .log().ifValidationFails() to log only failed requests.

Learn more: Logging & Extraction


Q15. How do you validate response headers and cookies?

Assertions are performed inside then() using:

  • .header()
  • .cookie()

Learn more: Advanced Validation


Serialization & Schema Validation (Q16–18)

Q16. What is a POJO class?

A POJO (Plain Old Java Object) represents the JSON payload as a Java object, making API requests more reusable, readable, and type-safe.

Learn more: Serialization & POJO


Q17. What is the difference between Serialization and Deserialization?

  • Serialization converts a Java object into JSON.
  • Deserialization converts JSON into a Java object.

Learn more: Serialization & POJO


Q18. What is JSON Schema Validation?

JSON Schema Validation verifies that an API response matches the expected response structure and data types.

It helps detect contract changes and missing fields.

Learn more: JSON Schema Validation


Authentication & API Chaining (Q19–21)

Q19. What authentication methods have you used in REST Assured?

Common authentication methods include:

  • Basic Authentication
  • Bearer Token
  • OAuth 2.0
  • API Key

Learn more: Authentication


Q20. How do you pass an authentication token?

Generate the token using the authentication API, extract it from the response, and include it in the Authorization header for subsequent requests.

Learn more: Authentication


Q21. What is API Chaining?

API Chaining extracts values such as IDs or authentication tokens from one API response and uses them in subsequent API requests.

It is commonly used for end-to-end API workflows.

Learn more: Advanced Validation


TestNG, Negative Testing & Framework Design (Q22–25)

Q22. How does REST Assured integrate with TestNG?

REST Assured tests are executed using TestNG features such as:

  • @Test
  • @BeforeClass
  • @AfterClass
  • Priorities
  • Groups
  • DataProvider

Learn more: TestNG Integration


Q23. How do you perform Negative API Testing?

Negative testing includes validating:

  • Invalid payloads
  • Missing headers
  • Invalid authentication
  • Invalid resource IDs
  • Expected error status codes and response schema

Learn more: Negative Testing & Error Handling


Q24. How do you design a REST Assured Framework?

A typical framework includes:

  • Base URI configuration
  • Request and Response Specifications
  • POJO classes
  • Utility classes
  • Test data management
  • Environment configuration
  • Reporting

Learn more: Framework Design


Q25. How do you handle dynamic authentication tokens and flaky APIs?

Generate authentication tokens dynamically for every execution instead of hardcoding them.

Handle unstable APIs using appropriate retry mechanisms and failure handling strategies.

Learn more: Real-Time Scenarios


Next Steps

Continue your REST Assured interview preparation with:

  • Complete REST Assured Guide
  • Complete API Testing Guide
  • REST Assured Practical Series
  • Complete Jenkins Guide