API Testing Junior cheat sheet: interview answers

Every question of this level with its correct answer and explanation, on one page for a quick review before the interview.

  1. 1. What is API testing?

    Correct answer: Checking an application's interface for programs directly, without the UI

    API tests send requests to endpoints and verify status codes, bodies, headers and side effects. They're faster and more stable than UI tests and reach cases the UI hides.

  2. 2. Why is API testing often done before UI testing?

    Correct answer: The API is ready earlier and bugs there are cheaper to find

    Backend endpoints usually exist before screens. Testing them early finds logic and validation bugs while the UI is still being built.

  3. 3. What does a REST API usually use to identify resources?

    Correct answer: URLs such as /users/42

    In REST, each resource has an address, and HTTP methods say what to do with it: GET /users/42 reads it, DELETE /users/42 removes it.

  4. 4. Which HTTP method should only read data?

    Correct answer: GET

    GET is a safe method: it must not change server state. A GET that deletes or updates something is a bug, since caches, crawlers and prefetching may call it.

  5. 5. Which method is usually used to create a new resource?

    Correct answer: POST

    POST /orders with a body creates an order. A successful response is often 201 Created with the new resource or its location.

  6. 6. What is the difference between PUT and PATCH?

    Correct answer: PUT replaces the whole resource, PATCH changes some fields

    Sending PUT with only one field may wipe the others, depending on the API. Testers check what happens to fields left out.

  7. 7. What do status codes starting with 2 mean?

    Correct answer: The request succeeded

    2xx means success (200 OK, 201 Created, 204 No Content). 4xx are client errors, 5xx server errors, 3xx redirects.

  8. 8. What do 4xx status codes mean?

    Correct answer: The problem is in the request from the client

    Examples: 400 bad input, 401 not authenticated, 403 not allowed, 404 not found. The client should change the request, not just retry.

  9. 9. What do 5xx status codes mean?

    Correct answer: The server failed to handle a valid request

    500, 502, 503 and 504 point to server or infrastructure problems. Invalid user input should never produce a 5xx; that's a bug.

  10. 10. A request with an invalid email returns 500. What is the problem?

    Correct answer: Validation errors should be 4xx; a 500 means unhandled input

    Bad input is the client's fault and should return 400 or 422 with a clear message. A 500 usually means an exception wasn't caught.

  11. 11. What does 201 Created usually come with?

    Correct answer: The new resource or a Location header pointing to it

    Clients need the new ID or URL. Testers check the body and the Location header, then GET the resource to confirm it exists.

  12. 12. When is 204 No Content used?

    Correct answer: When the request succeeded and there's no body to return

    It's common for DELETE or updates that return nothing. A 204 response must not have a body.

  13. 13. What is the difference between 401 and 403?

    Correct answer: 401: not authenticated; 403: authenticated but not allowed

    No or invalid token gives 401. A valid user trying to open another user's admin page gets 403.

  14. 14. What should GET /users/999 return if the user doesn't exist?

    Correct answer: 404 Not Found

    A missing resource is 404. Returning 200 with {} hides the problem from clients and makes errors hard to detect.

  15. 15. What should GET /users?name=zzz usually return when nothing matches?

    Correct answer: 200 OK with an empty list

    A search that finds nothing is a successful search. The collection exists; it's just empty.

  16. 16. What does 409 Conflict usually signal?

    Correct answer: The request clashes with current state, e.g. a duplicate

    Creating a user with an email that already exists, or updating a stale version, are typical cases.

  17. 17. What does 429 Too Many Requests mean?

    Correct answer: The client hit a rate limit and should slow down

    Often a Retry-After header says when to try again. Testers check the limit, the header and that normal use stays below it.

  18. 18. What does 415 Unsupported Media Type usually indicate?

    Correct answer: The body format, e.g. its Content-Type, isn't accepted

    Sending JSON with Content-Type: text/plain, or XML to a JSON-only API, can produce 415.

  19. 19. What does the Content-Type request header tell the server?

    Correct answer: The format of the body sent, e.g. application/json

    Content-Type describes the body. Accept says what the client wants back. Mixing them up is a common source of 415 and 406 errors.

  20. 20. What does the Accept header do?

    Correct answer: Tells the server which response formats the client accepts

    With Accept: application/json the server should return JSON or 406 Not Acceptable. This is part of content negotiation.

  21. 21. How is a bearer token usually sent?

    Correct answer: Authorization: Bearer <token>

    The Authorization header carries credentials. Tokens in URLs are risky because URLs end up in logs and browser history.

  22. 22. What is the difference between a path parameter and a query parameter?

    Correct answer: Path identifies a resource, query filters or modifies the result

    In /users/42/orders?status=paid&page=2, 42 is a path parameter and status, page are query parameters.

  23. 23. What is Postman mainly used for?

    Correct answer: Sending HTTP requests, organizing them and writing checks

    Postman lets you build requests, group them into collections, use environments and variables, and add test scripts.

  24. 24. What is a Postman collection?

    Correct answer: A saved, organized group of requests

    Collections hold requests in folders with shared auth, scripts and variables. They can be run all at once by the collection runner or Newman.

  25. 25. Why use environments in Postman?

    Correct answer: To switch values like base URL and tokens between dev, staging and prod

    With {{baseUrl}} in requests, switching from staging to dev means choosing another environment, not editing every request.

  26. 26. What does this Postman test check?

    pm.test("status is 200", () => {
      pm.response.to.have.status(200);
    });

    Correct answer: That the response status code is 200

    Tests run after the response arrives. Results show in the Test Results tab and in collection runs.

  27. 27. How do you reuse an ID from one response in the next request in Postman?

    const body = pm.response.json();
    pm.collectionVariables.set("orderId", body.id);

    Correct answer: Save it to a variable in a script and use {{orderId}}

    Chaining requests this way lets a collection create, read, update and delete the same resource in order.

  28. 28. What is Newman?

    Correct answer: A command-line runner for Postman collections

    newman run collection.json -e staging.json runs collections in CI and produces reports, with no Postman app needed.

  29. 29. What does this curl command do?

    curl -X POST https://api.example.com/users \
      -H "Content-Type: application/json" \
      -d '{"name":"Ann"}'

    Correct answer: Sends a POST with a JSON body to create a user

    -X sets the method, -H adds a header and -d sends the body. Adding a curl command to a bug report lets anyone reproduce it.

  30. 30. Which curl flag shows response headers along with the body?

    Correct answer: -i

    -i includes headers; -v shows the full exchange with request headers too, which helps debug auth and redirects.

  31. 31. How can you quickly get a failing request from a web app into a bug report?

    Correct answer: DevTools Network tab, right-click the request, Copy as cURL

    The copied command has the exact URL, headers and body. Remove secrets like tokens before sharing it.

  32. 32. What should an API bug report include?

    Correct answer: Request (method, URL, headers, body), response, expected result

    With the full request and response (plus environment and time), a developer can reproduce and find logs quickly.

  33. 33. What should you check in an API response besides the status code?

    Correct answer: Body content, headers, response time and side effects

    A 200 with wrong data, a missing header or a slow response is still a bug. Also check that the database or other systems changed as expected.

  34. 34. What is negative API testing?

    Correct answer: Sending invalid or unexpected input and checking it's rejected well

    Missing required fields, wrong types, too long strings and invalid IDs should give clear 4xx errors, not crashes or saved bad data.

  35. 35. A field accepts quantities from 1 to 100. Which values are boundary tests?

    Correct answer: 0, 1, 100 and 101

    Boundary value analysis checks just inside and just outside each limit, where off-by-one bugs hide.

  36. 36. What should happen when a required field is missing from a POST body?

    Correct answer: A 4xx error that names the missing field

    Clear validation messages let clients fix the request. Silently saving null leads to broken data later.

  37. 37. What do you test by sending "age": "twenty" instead of a number?

    Correct answer: That the API validates data types

    Type checks catch bugs where strings are stored as numbers or crash the server. The expected answer is a 400 or 422 with a message.

  38. 38. Which methods are idempotent by definition?

    Correct answer: GET, PUT and DELETE

    Repeating an idempotent request leaves the server in the same state. POST can create duplicates if repeated, which matters for retries.

  39. 39. What should happen when you DELETE the same resource twice?

    Correct answer: The second call changes nothing; often it returns 404 or 204

    The resource stays deleted, which is what idempotency means. Testers check the API documents and behaves consistently.

  40. 40. Why should API responses be checked for response time?

    Correct answer: Slow endpoints hurt users and may time out clients

    A simple threshold per endpoint (e.g. under 500 ms in a test environment) catches regressions like a missing index early.

  41. 41. What is a JSON Schema used for in API testing?

    Correct answer: Describing and checking the structure and types of JSON

    A schema states required fields, types and formats. Validating responses against it catches missing or renamed fields quickly.

  42. 42. What does OpenAPI (Swagger) describe?

    Correct answer: Endpoints, parameters, request and response formats of an API

    An OpenAPI file is a contract and documentation. Testers use it to design cases and tools can generate tests and mocks from it.

  43. 43. What is a mock server in API testing?

    Correct answer: A fake server that returns predefined responses

    Mocks let frontend and tests work before the real API exists, or simulate errors that are hard to trigger.

  44. 44. What does it mean that HTTP is stateless?

    Correct answer: Each request carries what the server needs to handle it

    The server doesn't remember earlier requests by itself. Tokens or cookies are sent with every request to identify the user.

  45. 45. How is API key authentication usually sent?

    Correct answer: In a header such as X-API-Key

    Keys identify an application. They should go in headers over HTTPS, not in URLs, and be rotated if leaked.

  46. 46. What is Basic authentication?

    Correct answer: Username and password Base64-encoded in Authorization

    Base64 is not encryption, so Basic auth is safe only over HTTPS. A missing or wrong header should return 401 with WWW-Authenticate.

  47. 47. Why does a request work in Postman but fail with a CORS error in the browser?

    Correct answer: CORS is enforced by browsers, not by Postman or curl

    Browsers block cross-origin responses unless the server sends the right CORS headers. It's a server configuration issue, not a client bug.

  48. 48. What is an OPTIONS request with Access-Control-Request-Method in the browser?

    Correct answer: A CORS preflight asking if the real request is allowed

    For non-simple requests, the browser asks first. If the preflight fails, the real request is never sent.

  49. 49. Why test pagination with page and limit parameters?

    Correct answer: To check limits, last pages, empty pages and no duplicates

    Typical bugs: missing or repeated items between pages, limit=0 or huge limits accepted, wrong total counts.

  50. 50. What should a test check when sorting results with sort=price?

    Correct answer: The order is correct, including ties and missing values

    Check ascending and descending, equal prices, nulls, and invalid sort fields, which should give a 400 rather than be ignored.

  51. 51. What should you test about date fields in an API?

    Correct answer: Format (e.g. ISO 8601), time zones and invalid dates

    Dates like 2026-02-30, missing time zones and daylight saving changes cause many bugs between systems.

  52. 52. Why send special characters like &, # or spaces in query parameters?

    Correct answer: To check URL encoding and that values aren't cut or misread

    An unencoded & splits a parameter, a # ends the URL. Clients must encode, and servers must decode correctly.

  53. 53. What is the main difference between GraphQL and REST for a tester?

    Correct answer: One endpoint, and the client chooses the fields

    Tests send queries and mutations to one URL. Errors often come in an errors array with status 200, so checking the status alone isn't enough.

  54. 54. A GraphQL response has status 200 and an errors array. Did the request succeed?

    Correct answer: Not fully; check errors as well as data

    GraphQL can return partial data with errors. Tests must assert that errors is absent when success is expected.

  55. 55. Why should API tests not depend on data that someone created by hand?

    Correct answer: Data may change or vanish, making tests fail randomly

    Tests that create their own data (and clean it up) are repeatable and can run in any environment.

  56. 56. What is a pre-request script in Postman for?

    Correct answer: Running code before a request, e.g. to set a timestamp or token

    Pre-request scripts prepare values such as dynamic IDs, signatures or fresh tokens.

  57. 57. Why shouldn't tokens and passwords be saved in shared Postman collections?

    Correct answer: Anyone with the collection could use or leak them

    Keep secrets in local environment values or a vault, and share collections without them.

  58. 58. What should happen when an API receives an unknown field in a request body?

    Correct answer: It follows its documented rule, ignore or reject

    Some APIs reject unknown fields to catch typos; others ignore them for compatibility. Either way, behaviour should be documented and consistent.

  59. 59. What is the risk of an API that returns more fields than the client needs?

    Correct answer: It may leak sensitive data like password hashes or emails

    Excessive data exposure is a common API vulnerability. Testers check responses don't include internal or private fields.

  60. 60. What is an IDOR bug?

    Correct answer: Accessing another user's data by changing an ID in the request

    If /orders/1001 shows another customer's order after you change the number, authorization is broken. Always test with two users.

  61. 61. What does Content-Length mismatch or a cut-off JSON body usually indicate?

    Correct answer: A problem in the transfer or the server stopping early

    Truncated bodies often come from crashes mid-response, proxies or timeouts. They should be logged and reported with the raw response.

  62. 62. What is HEAD useful for?

    Correct answer: Getting the headers of a resource without its body

    HEAD is like GET without the body. It checks existence, size or caching headers cheaply.

  63. 63. What is the main goal of a smoke test for an API?

    Correct answer: Quickly confirm key endpoints respond correctly after a deploy

    A few calls like health check, login and a main read confirm the build works before deeper testing.

  64. 64. What does a health check endpoint like /health usually tell you?

    Correct answer: Whether the service and its key dependencies are up

    Load balancers and monitors call it. Testers check it reports failures, e.g. when the database is down.

  65. 65. Why should API tests run in CI?

    Correct answer: To catch broken endpoints on every change automatically

    Running collections or code-based API tests on each merge request stops regressions before they reach users.

  66. 66. What does API versioning like /v1/orders help with?

    Correct answer: Changing the API without breaking existing clients

    Old clients keep using v1 while new ones move to v2. Testers check both versions while v1 is supported.

  67. 67. Why are HTTPS-only APIs important to check?

    Correct answer: Plain HTTP exposes tokens and data to anyone on the network

    Testers check that HTTP is redirected or refused and that tokens are never accepted over plain HTTP.

  68. 68. Are HTTP header names case-sensitive?

    Correct answer: No, Content-Type and content-type are the same header

    HTTP/2 even sends them in lowercase. Tests that compare header names exactly as strings may fail for no real reason.

  69. 69. How should you test a PATCH that updates a user's name?

    Correct answer: Check the name changed and other fields stayed the same

    Partial updates sometimes reset fields they shouldn't touch. A follow-up GET confirms the full state.

  70. 70. Why verify side effects after a successful POST?

    Correct answer: The API may answer 201 while data, emails or events are wrong

    Read the resource back, check the database or the message queue, or check that an email was sent.

  71. 71. What does a very long string, e.g. 10,000 characters, in a name field test?

    Correct answer: Length limits and how the API handles oversized input

    The API should reject it with a 400, not crash, truncate silently or slow down. Very large bodies can also be a denial-of-service risk.

  72. 72. Why test with Unicode such as emoji or Cyrillic in text fields?

    Correct answer: To check encoding, storage and length counting

    Wrong encoding turns names into ???; length checks may count bytes instead of characters.

  73. 73. What is the difference between authentication and authorization?

    Correct answer: Authentication checks who you are; authorization what you may do

    A valid token proves identity. Each endpoint must still check that this user may access this resource or action.

  74. 74. What should happen when a request uses an expired token?

    Correct answer: 401 with a clear error, and no data returned

    Testers check expired, malformed, revoked and missing tokens. Each should be rejected without leaking data.

  75. 75. What is a webhook from a tester's point of view?

    Correct answer: An API call the system sends to your URL when an event happens

    To test webhooks, you need an endpoint to receive them (e.g. a request catcher) and to check payload, signature and retries.