Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
QA interview question
Web, API & dataMiddleCommonTheory

What do the standard HTTP methods do, and which of them are safe or idempotent?

Answer

GET reads a representation; HEAD is GET semantics without response content; POST performs resource-specific processing; PUT creates or replaces the target state; PATCH applies partial modifications; DELETE removes the target; OPTIONS describes communication options and is used for CORS preflight; CONNECT creates a tunnel; TRACE is diagnostic loop-back. GET, HEAD, OPTIONS and TRACE are safe. GET, HEAD, PUT, DELETE, OPTIONS and TRACE are idempotent by HTTP semantics. POST is not idempotent by definition, and PATCH is not guaranteed to be idempotent.

Strong answer includes

  • covers GET/HEAD/POST/PUT/PATCH/DELETE/OPTIONS
  • safe versus idempotent distinction
  • PUT versus PATCH semantics

Practical example

Repeating PUT /users/42 with the same complete representation should leave the resource in the same intended state, while repeating POST /orders may create a second order unless the API implements its own idempotency mechanism.

#http#methods#idempotency#rest-api

Sources

MDN HTTP referenceMozilla · HTTP methods, messages, status codes, headers, cookies and cachingDOU — QA interview: 250+ questionsDOU · Coverage signal across Junior, Middle, Senior, AQA, web, mobile and practical topics