Skip to article
TOOLS. SYSTEMS. BETTER DECISIONS.
Stack & Method

The journal

GET, POST, PUT and DELETE: Trace Four Methods With One Example Record

Map four common HTTP methods to one fictional inventory record. Check request intent, the target URI and resulting state before relying on a response code.

Four blank task cards around one item card on a desk
Read each method together with the resource it targets.
Stack & MethodStack & Method

At a glance

GET retrieves a representation. POST asks the target resource to process submitted content. PUT creates or replaces state at the target URI. DELETE asks to remove the target resource’s association. Read the service contract to see exactly which methods and results it supports.

Run the three local PUT examples

GET, POST, PUT and DELETE are four common HTTP methods. Review them together on one fictional inventory record. The important detail is the method and the URI pairing. Then compare the documented response with what you expect the service to hold after the request.

Put the method beside the exact target

Imagine a collection at /items. Under this service’s fictional contract, POST to that collection creates a new item and the service assigns /items/17. GET to /items/17 retrieves the item’s representation. PUT to the same item URI asks the service to replace its state with the supplied representation. DELETE then requests that the service remove the target resource’s association. The service contract tells you which of those actions an actual route supports.

Fictional inventory example. Every path is local to the example.
Method and targetIntended actionWhat to verify
POST /itemsRequest creation under the collection’s contractResponse identifies the new item URI
GET /items/17Read the current recordRepresentation matches the response contract
PUT /items/17Replace state at the known targetRead the record back and check the new values
DELETE /items/17Remove the association for the targetCheck the contract’s response and follow-up state
Four rows pair POST with the collection and GET, PUT and DELETE with item 17.
Choose the method and URI together in your contract.

Read the standard’s method definitions RFC 9110, section 9.3: Method definitions.

Sources: IETF

Verify the example record before and after

Suppose the example item represents clips with a quantity of three. The first GET should return that data if you created it with the stated quantity. A later PUT replaces it with a quantity of five. Read the item again and verify five in the returned representation. If the example contract says the deleted item is unavailable, assert that result after DELETE. This checks a separate observation from the write status itself.

Four steps read 3 clips after creation, 3 after read, 5 after replacement and absent after removal.
Confirm the actual contract for each response and resulting state.

Read the 201 Created entry RFC 9110, section 15.3.2: 201 Created.

Sources: RFC 9110, section 9.3: Method definitions · RFC 9110, section 15.3.2: 201 Created

Check whether a repeat has the same intended effect

RFC 9110 defines idempotence by intended effect on the server. After two identical PUT calls the example quantity stays five, even if the responses differ. Retrying the collection POST after a missing response can create a second item if the service contract offers no safe way to avoid it. Record what the application actually promises, and use a test fixture to prove the outcome your caller relies on.

The quantity is five after the first request and remains five after the identical request.
The result you check here is the target effect. A response status can differ.
Two clipped notes beside each other on a desk
Keep the request outcome separate from the target’s final state.

Review one request flow

  • Write the intended effect and target first.
  • Record the exact starting state.
  • Assert the documented response and resulting state.
  • Check retry behaviour against the specific API contract.

Request intent and repeat behavior are separate checks.

Same intended effect

Repeating identical requests with an idempotent method has the same intended effect on the target.

Same returned status

The responses can differ when the first request changes the starting state. Read the contract and verify the final state.

Check the specification’s meaning of idempotent RFC 9110, section 9.2.2: Idempotent methods.

For the related task, see Read the conditional GET example.

Sources: RFC 9110, section 9.2.2: Idempotent methods · RFC 9110, section 9.3: Method definitions

Frequently asked questions

Does POST always create a record?

No. POST requests target-specific processing. This inventory collection is an example where its documented processing creates an item.

Can PUT create an item?

The specification allows PUT to create at the target URI when supported and the target had no current representation.

Does DELETE prove the storage bytes were erased?

Its request semantics concern the target resource association. The underlying data retention and business effects depend on the service.

Does using an idempotent method guarantee the same response twice?

Check the intended effect. Status or timestamps can differ, even when the target effect remains the same.

Stack & MethodStack & Method

Test the three PUT result cases

Check status and content for create, update with body, and update without body.

Run the three local PUT examples

Continue with a related guide

References

Your privacy choices

Optional analytics helps us improve these guides. It stays off until you allow it. Privacy details