Using POST where PUT was appropriate is a common real-world bug source because POST is not idempotent, so retried or duplicated requests, such as from a flaky network or a double-click, can create duplicate records instead of safely repeating the same update.
A checkout form using POST for order submission created duplicate orders when a user's network hiccuped and their browser silently retried the request; switching to an idempotent PUT with a client-generated order ID fixed the duplication.
// Make "create order" safe to retry: the client sends a unique key per order
@PostMapping("/orders")
public ResponseEntity<OrderDto> create(@RequestHeader("Idempotency-Key") String key,
@Valid @RequestBody CreateOrder request) {
Optional<OrderDto> existing = orderService.findByIdempotencyKey(key);
if (existing.isPresent()) {
return ResponseEntity.ok(existing.get()); // retry: return the same order
}
OrderDto created = orderService.create(request, key); // unique DB constraint on key
return ResponseEntity.status(HttpStatus.CREATED).body(created);
}
// Alternative: let the client choose the id and use PUT, which is idempotent
@PutMapping("/orders/{orderId}")
public OrderDto createOrReplace(@PathVariable UUID orderId, @RequestBody CreateOrder request) {
return orderService.upsert(orderId, request);
}A concise interview answer is
I've seen POST used for update operations cause duplicate records when a request got retried due to a flaky connection, since POST isn't idempotent. The fix was switching to PUT with a stable resource identifier so retries just repeat the same update safely, and adding idempotency checks for cases where POST for creation was still necessary.
Last updated: 11 November 2026
Previous question: Name five annotations you use to build a REST API in Spring Boot.