StudyFox
कीमतेंब्लॉगएक्सटेंशनमुफ़्त टूल
  • कीमतें
  • ब्लॉग
  • एक्सटेंशन
  • मुफ़्त टूल
  • शुरू करेंसाइन इन
StudyFox

अपने नोट्स, PDF और स्लाइड्स को फ़्लैशकार्ड, क्विज़, नोट्स और माइंड मैप में बदलें।

StudyFox खोलें

स्टडी टूल्स

  • होमवर्क हेल्पर
  • नोट मेकर
  • फ़्लैशकार्ड मेकर
  • क्विज़ मेकर
  • माइंड मैप मेकर

प्रोडक्ट

  • कीमतें
  • Chrome एक्सटेंशन
  • मुफ़्त एक्सटेंशन
  • स्टडी सेट देखें
  • ब्लॉग

सहायता

  • सहायता केंद्र
  • संपर्क करें
  • गोपनीयता नीति
  • सेवा की शर्तें

तुलना करें

  • Chegg का विकल्प
  • Course Hero का विकल्प
  • Coursology का विकल्प
  • Photomath का विकल्प
  • Gauthmath का विकल्प
  • PhotoSolve का विकल्प
  • CollegeTools का विकल्प
  • Transcript का विकल्प
  • SmartSolve का विकल्प
  • Homeworkify का विकल्प
  • AnswersAi का विकल्प
  • StudyX का विकल्प
  • Quizlet का विकल्प
  • Anki का विकल्प
  • Knowt का विकल्प
  • Brainscape का विकल्प
  • सभी तुलनाएँ

© 2026 StudyFox AI. सर्वाधिकार सुरक्षित।

  • X
  • Discord
  • Instagram
ExploreEngineering & TechWeb DevelopmentREST APIs: Design, HTTP and Fetch Quiz

Quiz · Medium

REST APIs: Design, HTTP and Fetch Quiz

Twenty-three questions on REST resource design, method semantics, status codes, caching with ETags, pagination, versioning, URLs and HTTP messages, and calling APIs with fetch.

by Kill h.23 questionsCreated Nov 20, 2026, 08:26 PM
Web Development· APIsTags#api#rest#http#fetch

23 questions

  1. 1

    Which URL and method best follow REST naming conventions for fetching all orders of user 42?

    • A

      GET /getOrdersForUser?id=42

    • B

      POST /users/42/getOrders

    • GET /users/42/orders

    • D

      GET /user/42/order/list

    REST URLs name resources with nouns and let the HTTP method carry the verb. GET /users/42/orders reads the orders collection of user 42. The other options put verbs or actions in the path, or misuse POST for a read.

  2. 2

    A client POSTs a new user and the server creates it. Which response is most appropriate?

    • 201 Created with a Location header pointing to the new user

    • B

      200 OK with an empty body

    • C

      204 No Content

    • D

      302 Found redirecting to the login page

    201 Created signals that a new resource exists, and Location tells the client where. 200 is acceptable in sloppy APIs but less precise; 204 gives no information about the new resource; 302 is a redirect.

  3. 3

    A payment client retries PUT /orders/7 three times after timeouts. The server applies the update. What is the result?

    • A

      Three updates are applied, charging three times

    • B

      An error, because retries are forbidden

    • C

      The server creates three orders

    • The same final state as one request, because PUT is idempotent

    PUT replaces the resource with the supplied representation, so repeating it leaves the same state. POST would be the risky one. (The side effects of your own code, such as charging, still need care.)

  4. 4

    In this URL diagram, what is the part ?color=red?

    • A

      Fragment

    • Query string

    • C

      Path

    • D

      Scheme

    The query string starts at ? and carries key=value pairs. The fragment starts at # and the path is /shoes.

  5. 5

    True or false: the fragment (the part after #) is sent to the server in the HTTP request.

    • A

      True

    • False

    False. Browsers keep the fragment for themselves (scrolling to an element or client-side routing). Only the path and query reach the server.

  6. 6

    In the HTTP message diagram, which element tells the receiver that the headers are over?

    • A

      The status line

    • B

      The Content-Type header

    • C

      The body

    • A blank line

    An empty line separates headers from the body. Content-Type describes the body but does not end the headers.

  7. 7

    A client sends If-None-Match: "abc123", and the resource has not changed. What should the server reply?

    • 304 Not Modified with no body

    • B

      200 OK with the full body

    • C

      204 No Content

    • D

      412 Precondition Failed

    The client holds a cached copy with ETag abc123. If it is still current, 304 lets the client reuse its copy and saves bandwidth. 412 is for failed If-Match/If-Unmodified-Since preconditions.

  8. 8

    Which header value should be used for a response containing a user's bank statement that must never be stored in shared or browser caches?

    • A

      Cache-Control: max-age=3600

    • B

      Cache-Control: no-cache

    • Cache-Control: no-store

    • D

      Cache-Control: public

    no-store forbids storing the response. no-cache still lets caches store it and only requires revalidation before reuse; public and max-age encourage caching.

  9. 9

    A social feed API has new posts inserted constantly. Which pagination style avoids duplicated or skipped items while scrolling?

    • A

      Offset/limit with page numbers

    • B

      Returning everything in one response

    • C

      Random sampling

    • Cursor-based pagination (e.g. ?after=<last_id>)

    With offset pagination, an insert between page loads shifts the rows and causes duplicates or gaps. A cursor anchors to a specific item, so the next page starts exactly after it.

  10. 10

    Which change to an existing v1 API response is a breaking change?

    • A

      Adding a new optional field nickname

    • Renaming the field email to emailAddress

    • C

      Adding a new endpoint /v1/reports

    • D

      Adding a new optional query parameter

    Clients written against the old contract look for email, so renaming (or removing, or changing the type of) a field breaks them. Additive changes are normally safe.

  11. 11

    What does HATEOAS add to a REST API?

    • A

      Faster database queries

    • B

      Encryption of the response body

    • Links in responses that tell clients which resources and actions are available next

    • D

      Automatic API versioning

    Hypermedia as the engine of application state means the server drives the client with links (next, cancel, pay) instead of the client hard-coding URLs. It is level 3 of the Richardson maturity model.

  12. 12

    Which error response is best for a form submission whose email field is invalid?

    • 400 or 422 with a JSON body that names the field and the problem

    • B

      200 OK with the body error

    • C

      500 Internal Server Error

    • D

      404 Not Found

    A client error status (400 Bad Request or 422 Unprocessable Content) plus a structured body lets the UI highlight the field. 200 hides the failure, 500 blames the server, and 404 means the resource does not exist.

  13. 13

    A request starts generating a large report that takes about two minutes. What is the best REST response?

    • 202 Accepted with a Location header for a status resource the client can poll

    • B

      Hold the connection open for two minutes

    • C

      200 OK with an empty body

    • D

      301 Moved Permanently

    202 means 'accepted but not finished'. The Location URL (/jobs/123) reports progress and eventually links to the result. Long-held connections hit proxy and client timeouts.

  14. 14

    What is wrong with this code?

    const res = await fetch('/api/users/999'); const user = await res.json();

    • A

      fetch needs a callback instead of await

    • B

      res.json() is synchronous

    • It does not check res.ok: a 404 or 500 response does not make fetch reject

    • D

      fetch cannot call relative URLs

    fetch rejects only on network failure, not on HTTP error statuses. Check res.ok (or the status) before parsing. res.json() returns a Promise, and relative URLs work in browsers.

  15. 15

    Which request header tells the server which response formats the client can handle?

    • A

      Content-Type

    • Accept

    • C

      Authorization

    • D

      Host

    Accept (for example application/json) drives content negotiation. Content-Type describes the body that is being sent.

  16. 16

    A client sends PATCH /users/42 with the JSON body {"email":"[email protected]"}. What happens to the user's name?

    • A

      It is set to null

    • B

      The request is rejected because name is missing

    • C

      The user is deleted and recreated

    • It is unchanged, because PATCH sends only the fields to modify

    PATCH is a partial update; omitted fields stay as they are. PUT would replace the whole representation, and a missing name would typically be treated as removed or invalid.

  17. 17

    Which HTTP method is idempotent?

    • A

      POST

    • B

      PATCH, always

    • DELETE

    • D

      None of them

    DELETE is idempotent: deleting the same resource twice leaves the same final state (it may return 404 the second time, but the state is the same). POST is not, and PATCH is not guaranteed to be.

  18. 18

    Two editors load a document with ETag v5. Editor A saves with If-Match: v5 and succeeds. Editor B then saves with If-Match: v5. What should B receive?

    • 412 Precondition Failed

    • B

      200 OK, overwriting A's change

    • C

      204 No Content

    • D

      301 Moved Permanently

    The ETag is now v6, so B's precondition fails. 412 prevents the lost update; B must reload, merge and try again.

  19. 19

    What is the main benefit of HTTP/2 over HTTP/1.1 for API-heavy pages?

    • A

      It makes responses smaller by removing headers

    • B

      It removes the need for TLS

    • C

      It turns POST into GET

    • Many requests can be multiplexed over a single connection

    HTTP/2 interleaves many streams on one TCP connection and compresses headers (HPACK), reducing connection overhead and head-of-line blocking at the HTTP level. Most browsers use it only over TLS, but it does not 'remove' TLS.

  20. 20

    Which statement describes a violation of REST's statelessness constraint?

    • A

      The client sends an auth token with every request

    • The server keeps per-client conversation state in memory and relies on it between requests

    • C

      The API uses JSON

    • D

      The server returns cache headers

    Stateless means each request must contain all the information needed to process it. Server-side per-client conversation state ties a client to a particular server and breaks scaling.

  21. 21

    An API exposes a single URL POST /api and the JSON body says {"action": "getUser", "id": 42}. Which Richardson maturity level is this?

    • A

      Level 1

    • Level 0

    • C

      Level 2

    • D

      Level 3

    Level 0 uses HTTP as a tunnel to a single endpoint (RPC style). Level 1 introduces separate resources, level 2 uses HTTP verbs and status codes properly, and level 3 adds hypermedia.

  22. 22

    Why does a browser perform a DNS lookup before the HTTP request in this diagram?

    • A

      To check that the server supports HTTPS

    • B

      To download the page's CSS

    • C

      To prove it is not a robot

    • To convert the host name into an IP address it can connect to

    Network connections need an IP address. DNS resolves www.wikipedia.org to one; only then can the browser send the HTTP GET. Image: Michel Bakni, CC BY-SA 4.0, via Wikimedia Commons.

  23. 23

    A client sends Content-Type: text/xml to an endpoint that only accepts JSON. Which status is the best fit?

    • 415 Unsupported Media Type

    • B

      404

    • C

      401

    • D

      301

    415 says the server refuses the request because the body's media type is not supported. 404 would mean the resource is missing, 401 is about authentication.