All subjects.NET · 45 questions · 11 junior / 22 mid / 12 senior

Web API & REST quiz and interview questions

Building and consuming APIs is a daily job for backend developers, so interviews test REST basics hard: which HTTP verb to use, which status code to return, what idempotent means, and how authentication, CORS and versioning work.

Web API & REST quiz45 questions in the bank · 10 per round
Level
Question type
Mode

Web API & REST: key concepts

REST
An API style built around resources (URLs like /orders/42) and standard HTTP verbs. Each request is stateless — it carries everything the server needs.
HTTP verbs
GET reads, POST creates, PUT replaces, PATCH updates part of a resource, DELETE removes. GET, PUT and DELETE are idempotent.
Status codes
2xx success (200, 201 Created, 204), 4xx client errors (400, 401, 403, 404, 429), 5xx server errors (500).
Authentication
APIs usually use bearer tokens such as JWTs: a signed token with claims, sent in the Authorization header.
CORS
Browsers block cross-origin calls unless the API sends CORS headers allowing that origin.
Versioning and docs
Version breaking changes (/v1/, headers) and describe the API with OpenAPI/Swagger.

All 45 Web API & REST questions with answers

Try each one first, then open the answer. Making a class test? Use the test maker.

  1. juniorConcepts

    Which HTTP verb is normally used to create a new resource?

    • A. GET
    • B. POST
    • C. DELETE
    • D. HEAD
    Show answer

    B. POST — POST /orders creates an order; the response is usually 201 Created with the new resource's URL.

  2. juniorConcepts

    What is the difference between PUT and PATCH?

    • A. None
    • B. PUT replaces the whole resource; PATCH changes only some fields
    • C. PATCH deletes
    • D. PUT is read-only
    Show answer

    B. PUT replaces the whole resource; PATCH changes only some fields — PUT /users/7 sends the full user; PATCH /users/7 can send just { "email": "..." }.

  3. juniorConcepts

    Which status code fits a successful create?

    • A. 200 OK
    • B. 201 Created
    • C. 204 No Content
    • D. 302 Found
    Show answer

    B. 201 Created — 201 tells the client a new resource exists, usually with a Location header pointing to it.

  4. juniorConcepts

    The client sent invalid JSON fields. Which status code?

    • A. 404
    • B. 400 Bad Request
    • C. 500
    • D. 201
    Show answer

    B. 400 Bad Request — 400 means the request itself is wrong. 404 means the resource doesn't exist; 500 means the server failed.

  5. midConcepts

    What is the difference between 401 and 403?

    • A. None
    • B. 401: not authenticated (who are you?); 403: authenticated but not allowed
    • C. 403 means the server crashed
    • D. 401 means not found
    Show answer

    B. 401: not authenticated (who are you?); 403: authenticated but not allowed — No or invalid token → 401. Valid token but missing the Admin role → 403.

  6. midConcepts

    Which HTTP verb is NOT idempotent?

    • A. GET
    • B. PUT
    • C. DELETE
    • D. POST
    Show answer

    D. POST — Repeating a POST can create duplicates. Repeating GET, PUT or DELETE leaves the server in the same state.

  7. midConcepts

    What does "stateless" mean in REST?

    • A. No database
    • B. Each request carries everything needed (e.g. a token); the server keeps no session between requests
    • C. Responses are never cached
    • D. Only GET is allowed
    Show answer

    B. Each request carries everything needed (e.g. a token); the server keeps no session between requests — Statelessness makes APIs easy to scale — any server instance can handle any request.

  8. juniorPredict the output

    A client requests GET /products/999 and no product 999 exists. What status code is returned?

    [HttpGet("{id}")]
    public ActionResult<Product> Get(int id)
    {
        var p = _repo.Find(id);
        if (p == null) return NotFound();
        return p;
    }
    • A. 200
    • B. 204
    • C. 404
    • D. 500
    Show answer

    C. 404 — NotFound() produces a 404 response.

  9. midConcepts

    What is a JWT?

    • A. A JavaScript test
    • B. A signed token holding claims (user id, roles, expiry) that the server can verify without a session
    • C. An encrypted database
    • D. A web template
    Show answer

    B. A signed token holding claims (user id, roles, expiry) that the server can verify without a session — The signature proves the token wasn't changed. Note: the payload is only Base64-encoded, not encrypted — never put secrets in it.

  10. midConcepts

    Your React app on app.example.com can't call api.example.com from the browser. What is the likely cause?

    • A. The API is down
    • B. CORS — the API doesn't allow that origin
    • C. JSON is invalid
    • D. DNS
    Show answer

    B. CORS — the API doesn't allow that origin — Configure the API's CORS policy to allow the front-end origin (and only that origin).

More subjects

Need software for your business instead? I'm an AI automation & full-stack developer — see what I build.

Chat on WhatsApp