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. 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. 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. What does a REST API usually use to identify resources?
Correct answer: URLs such as
/users/42In REST, each resource has an address, and HTTP methods say what to do with it:
GET /users/42reads it,DELETE /users/42removes it.4. Which HTTP method should only read data?
Correct answer:
GETGETis a safe method: it must not change server state. AGETthat deletes or updates something is a bug, since caches, crawlers and prefetching may call it.5. Which method is usually used to create a new resource?
Correct answer:
POSTPOST /orderswith a body creates an order. A successful response is often201 Createdwith the new resource or its location.6. What is the difference between
PUTandPATCH?Correct answer:
PUTreplaces the whole resource,PATCHchanges some fieldsSending
PUTwith only one field may wipe the others, depending on the API. Testers check what happens to fields left out.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. What do 4xx status codes mean?
Correct answer: The problem is in the request from the client
Examples:
400bad input,401not authenticated,403not allowed,404not found. The client should change the request, not just retry.9. What do 5xx status codes mean?
Correct answer: The server failed to handle a valid request
500,502,503and504point to server or infrastructure problems. Invalid user input should never produce a 5xx; that's a bug.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
400or422with a clear message. A500usually means an exception wasn't caught.11. What does
201 Createdusually come with?Correct answer: The new resource or a
Locationheader pointing to itClients need the new ID or URL. Testers check the body and the
Locationheader, thenGETthe resource to confirm it exists.12. When is
204 No Contentused?Correct answer: When the request succeeded and there's no body to return
It's common for
DELETEor updates that return nothing. A204response must not have a body.13. What is the difference between
401and403?Correct answer:
401: not authenticated;403: authenticated but not allowedNo or invalid token gives
401. A valid user trying to open another user's admin page gets403.14. What should
GET /users/999return if the user doesn't exist?Correct answer:
404 Not FoundA missing resource is
404. Returning200with{}hides the problem from clients and makes errors hard to detect.15. What should
GET /users?name=zzzusually return when nothing matches?Correct answer:
200 OKwith an empty listA search that finds nothing is a successful search. The collection exists; it's just empty.
16. What does
409 Conflictusually 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. What does
429 Too Many Requestsmean?Correct answer: The client hit a rate limit and should slow down
Often a
Retry-Afterheader says when to try again. Testers check the limit, the header and that normal use stays below it.18. What does
415 Unsupported Media Typeusually indicate?Correct answer: The body format, e.g. its
Content-Type, isn't acceptedSending JSON with
Content-Type: text/plain, or XML to a JSON-only API, can produce415.19. What does the
Content-Typerequest header tell the server?Correct answer: The format of the body sent, e.g.
application/jsonContent-Typedescribes the body.Acceptsays what the client wants back. Mixing them up is a common source of415and406errors.20. What does the
Acceptheader do?Correct answer: Tells the server which response formats the client accepts
With
Accept: application/jsonthe server should return JSON or406 Not Acceptable. This is part of content negotiation.21. How is a bearer token usually sent?
Correct answer:
Authorization: Bearer <token>The
Authorizationheader carries credentials. Tokens in URLs are risky because URLs end up in logs and browser history.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,42is a path parameter andstatus,pageare query parameters.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. 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. 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. 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. 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. What is Newman?
Correct answer: A command-line runner for Postman collections
newman run collection.json -e staging.jsonruns collections in CI and produces reports, with no Postman app needed.29. What does this
curlcommand 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
-Xsets the method,-Hadds a header and-dsends the body. Adding a curl command to a bug report lets anyone reproduce it.30. Which
curlflag shows response headers along with the body?Correct answer:
-i-iincludes headers;-vshows the full exchange with request headers too, which helps debug auth and redirects.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. 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. What should you check in an API response besides the status code?
Correct answer: Body content, headers, response time and side effects
A
200with 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. 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. 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. 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. 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. Which methods are idempotent by definition?
Correct answer:
GET,PUTandDELETERepeating an idempotent request leaves the server in the same state.
POSTcan create duplicates if repeated, which matters for retries.39. What should happen when you
DELETEthe 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. 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. 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. 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. 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. 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. How is API key authentication usually sent?
Correct answer: In a header such as
X-API-KeyKeys identify an application. They should go in headers over HTTPS, not in URLs, and be rotated if leaked.
46. What is Basic authentication?
Correct answer: Username and password Base64-encoded in
AuthorizationBase64 is not encryption, so Basic auth is safe only over HTTPS. A missing or wrong header should return
401withWWW-Authenticate.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. What is an
OPTIONSrequest withAccess-Control-Request-Methodin 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. Why test pagination with
pageandlimitparameters?Correct answer: To check limits, last pages, empty pages and no duplicates
Typical bugs: missing or repeated items between pages,
limit=0or huge limits accepted, wrong total counts.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. 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. 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. 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
errorsarray with status 200, so checking the status alone isn't enough.54. A GraphQL response has status 200 and an
errorsarray. Did the request succeed?Correct answer: Not fully; check
errorsas well asdataGraphQL can return partial data with errors. Tests must assert that
errorsis absent when success is expected.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. 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. 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. 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. 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. What is an IDOR bug?
Correct answer: Accessing another user's data by changing an ID in the request
If
/orders/1001shows another customer's order after you change the number, authorization is broken. Always test with two users.61. What does
Content-Lengthmismatch 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. What is
HEADuseful for?Correct answer: Getting the headers of a resource without its body
HEADis likeGETwithout the body. It checks existence, size or caching headers cheaply.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. What does a health check endpoint like
/healthusually 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. 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. What does API versioning like
/v1/ordershelp 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. 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. Are HTTP header names case-sensitive?
Correct answer: No,
Content-Typeandcontent-typeare the same headerHTTP/2 even sends them in lowercase. Tests that compare header names exactly as strings may fail for no real reason.
69. How should you test a
PATCHthat 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
GETconfirms the full state.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. 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. 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. 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. What should happen when a request uses an expired token?
Correct answer:
401with a clear error, and no data returnedTesters check expired, malformed, revoked and missing tokens. Each should be rejected without leaking data.
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.