Skip to main content
REST • Microservices • Automation

REST API Testing Interview Questions & Answers

A comprehensive, 2026 production-grade guide for QA Engineers and SDETs. Covers HTTP method idempotency, asynchronous status codes, OAuth 2.0 security, JSON Schema contract assertions, and REST Assured framework design.

Author:Shivam Singh (Founder)
Updated:October 2026 Edition
Tools:REST Assured • Postman • Java • WireMock
Reading Time:16 mins • 2,500+ words

Categories Covered

HTTP Architecture & MethodsStatus Codes & ContractsSecurity & AuthenticationAutomation Frameworks (REST Assured)Contract & Schema TestingResilience & PerformanceMicroservices & CI Gates
HTTP Architecture & Methods

1. What is the precise architectural difference between POST, PUT, and PATCH, and which methods are idempotent?

POST is used to create a new subordinate resource; it is neither safe nor idempotent (calling POST twice creates two separate records). PUT is used to replace an entire resource at a known URI; it is idempotent (executing the identical PUT request multiple times produces the identical server state). If the resource does not exist, PUT can create it or return 404 depending on API contract. PATCH performs partial updates, modifying only specified attributes without requiring the complete payload representation; PATCH is generally non-idempotent by default unless controlled with version tokens.

ApiTestSnippet.javaJava
// 1. POST: Creates a new user record (non-idempotent)
// POST /api/v1/users -> Status 201 Created

// 2. PUT: Completely replaces the user representation (idempotent)
// PUT /api/v1/users/42 -> Status 200 OK
// Payload: { "name": "Jane", "email": "jane@example.com", "role": "admin" }

// 3. PATCH: Partially updates only specific fields
// PATCH /api/v1/users/42 -> Status 200 OK
// Payload: { "role": "super-admin" }
💡
Interviewer Insight: In interviews, clearly define 'Idempotency': An operation is idempotent if executing it once has the same effect on the server system as executing it N times consecutively.
Status Codes & Contracts

2. How do you distinguish between 200 OK, 201 Created, and 202 Accepted in asynchronous microservices?

Status 200 OK indicates that the request succeeded and the response payload contains the resource representation. Status 201 Created indicates that the request succeeded and resulted in the immediate creation of a new resource, typically accompanied by a `Location` header pointing to the new URI. Status 202 Accepted indicates that the request has been received and validated, but processing has been enqueued asynchronously (e.g., publishing an event to Kafka or RabbitMQ) and is not yet complete. The client receives a polling status URL or job ID to check execution progress.

ApiTestSnippet.javaJava
// Asynchronous batch job dispatch returning 202 Accepted
given()
    .contentType(ContentType.JSON)
    .body("{\"reportType\": \"ANNUAL_AUDIT\"}")
.when()
    .post("/api/v1/reports/async-generate")
.then()
    .statusCode(202)
    .header("Location", containsString("/api/v1/jobs/"))
    .body("status", equalTo("QUEUED"));
💡
Interviewer Insight: When testing 202 Accepted flows, mention how you write automated polling tests with Awaitility in Java to verify the asynchronous job eventually reaches COMPLETED state.
Status Codes & Contracts

3. What is the fundamental difference between 401 Unauthorized and 403 Forbidden, and how do you test for BOLA (IDOR)?

401 Unauthorized means 'Unauthenticated' — the client has not provided valid credentials, or the Bearer token is missing, expired, or invalid. The client can retry with valid credentials. 403 Forbidden means 'Authenticated, but unauthorized' — the server knows who the client is, but their role or permissions deny access to the requested resource. Retrying with the same token will never succeed. To test for Broken Object Level Authorization (BOLA / IDOR): Authenticate as User A, obtain User A's token, and attempt to fetch or update User B's resource (`GET /api/v1/accounts/{userB_id}`). The API must return 403 or 404, never 200.

ApiTestSnippet.javaJava
// Testing for BOLA / IDOR vulnerability
String userAToken = getAuthToken("userA@test.com", "Password123!");
String userBAccountId = "ACC-998822";

given()
    .header("Authorization", "Bearer " + userAToken)
.when()
    .get("/api/v1/banking/accounts/" + userBAccountId)
.then()
    // Must reject cross-tenant account access!
    .statusCode(anyOf(is(403), is(404)));
💡
Interviewer Insight: You can practice testing role-based authentication and token headers against the TesterRank Banking Practice API at /api-docs.
Security & Authentication

4. How does OAuth 2.0 Client Credentials Grant differ from Authorization Code Grant, and how do you automate token refresh?

Client Credentials Grant is machine-to-machine authentication (M2M) where your automation framework sends a `client_id` and `client_secret` directly to the `/token` endpoint without user browser interaction. Authorization Code Grant involves an interactive browser redirect where a user authenticates, a temporary auth code is returned, and then exchanged for an Access Token and Refresh Token. In automated API suites, we typically use Client Credentials or directly post to an internal authentication fixture to receive a Bearer token, caching it in memory until the `expires_in` duration elapses.

ApiTestSnippet.javaJava
// Automating OAuth 2.0 Token Generation in REST Assured
public String getOAuth2Token() {
    return given()
        .formParam("grant_type", "client_credentials")
        .formParam("client_id", Config.CLIENT_ID)
        .formParam("client_secret", Config.CLIENT_SECRET)
    .when()
        .post("/oauth/token")
    .then()
        .statusCode(200)
        .extract()
        .path("access_token");
}
💡
Interviewer Insight: Mention that your framework caches the access token across tests and only requests a new token when current timestamp exceeds expiry time to avoid hitting auth rate limits.
Automation Frameworks (REST Assured)

5. How do you design an enterprise-grade REST Assured test automation framework with reusable request specifications and filters?

In production frameworks, you should never repeat base URIs, content-type headers, or authentication tokens across individual test methods. Instead, encapsulate common configurations inside reusable `RequestSpecification` and `ResponseSpecification` builders. Furthermore, register custom `Filters` to automatically log request/response payloads upon failure, attach API traces to Allure reports, and calculate endpoint response latency.

ApiTestSnippet.javaJava
public class BaseApiTest {
    protected static RequestSpecification requestSpec;
    protected static ResponseSpecification responseSpec;

    @BeforeSuite
    public void setupSpecifications() {
        requestSpec = new RequestSpecBuilder()
            .setBaseUri("https://www.testerrank.com/api/v1")
            .setContentType(ContentType.JSON)
            .addHeader("Accept", "application/json")
            .addFilter(new RequestLoggingFilter(LogDetail.URI))
            .addFilter(new ErrorLoggingFilter()) // Logs full details ONLY if status >= 400
            .build();

        responseSpec = new ResponseSpecBuilder()
            .expectResponseTime(lessThan(3000L)) // 3-second SLA
            .build();
    }
}
💡
Interviewer Insight: Senior QA interviewers love to hear about `ErrorLoggingFilter()`: it keeps test logs clean when tests pass, but dumps full headers and body when an assertion fails.
Contract & Schema Testing

6. Why is JSON Schema validation crucial in API automation, and how do you implement it in REST Assured?

Validating individual response fields (like `name` or `id`) only asserts value correctness; it does not protect your microservices against schema drift, unintended data type changes (e.g., an ID changing from Integer to String), or deleted required attributes. JSON Schema validation verifies the entire structural contract of the payload in a single line using a standardized JSON schema specification.

ApiTestSnippet.javaJava
import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath;

@Test
public void verifyProductCatalogSchema() {
    given()
        .spec(requestSpec)
    .when()
        .get("/products/101")
    .then()
        .statusCode(200)
        // Validates entire contract against /resources/schemas/product-schema.json
        .body(matchesJsonSchemaInClasspath("schemas/product-schema.json"));
}
💡
Interviewer Insight: Explain that JSON Schema testing catches breaking backend changes before frontend UI automated tests even begin execution in CI.
Resilience & Performance

7. How do you test API rate limiting, throttle boundaries, and HTTP 429 Too Many Requests responses?

Rate limiting prevents Denial of Service (DoS) and ensures fair tenant usage. To test it: 1) Trigger rapid requests in a loop exceeding the configured threshold (e.g., 60 requests/minute). 2) Assert that initial calls return 200 OK, while calls beyond the limit return HTTP 429 Too Many Requests. 3) Verify that the response includes standard headers such as `X-RateLimit-Limit`, `X-RateLimit-Remaining: 0`, and `Retry-After: 30`. 4) Automate a pause matching the `Retry-After` duration and verify subsequent calls succeed again.

ApiTestSnippet.javaJava
for (int i = 0; i < 65; i++) {
    Response res = given().get("/api/v1/resource");
    if (i < 60) {
        assertEquals(res.statusCode(), 200);
    } else {
        assertEquals(res.statusCode(), 429);
        assertTrue(res.headers().hasHeaderWithName("Retry-After"));
    }
}
💡
Interviewer Insight: You can practice boundary testing and header validations on TesterRank's practice shopping endpoints at /shopping.
Microservices & CI Gates

8. When and why should you use WireMock or API stubbing instead of hitting live external third-party endpoints?

Hitting live third-party APIs (e.g., Stripe, Twilio, Razorpay) during automated regression runs causes critical issues: 1) Real money/SMS charges, 2) Flakiness from third-party outages or rate limits, and 3) Inability to simulate catastrophic edge cases (500 internal server errors, malformed payloads, 30-second timeouts). Tools like WireMock or Mockoon allow your CI suite to spin up a local HTTP stub server that simulates exact success, failure, and latency scenarios deterministically.

ApiTestSnippet.javaJava
// Stubbing a 504 Gateway Timeout in WireMock
stubFor(post(urlEqualTo("/v1/payments"))
    .willReturn(aResponse()
        .withStatus(504)
        .withFixedDelay(5000)
        .withBody("{\"error\": \"Bank network gateway timeout\"}")));
💡
Interviewer Insight: In interviews, mention that contract testing with tools like Pact or WireMock stubs ensures fast, cost-free, and fully reproducible CI pipelines.
Hands-On API Practice

Ready to test real REST API endpoints?

TesterRank includes dedicated mock backend APIs for e-commerce, banking, and authentication. Practice sending GET, POST, PUT, and token requests right in your browser or Postman.