What is the difference between PUT and PATCH?
PUT generally replaces the target resource representation and is idempotent; PATCH applies partial modifications.
The question library
Explore practical questions, clear explanations, and code examples across developer technologies.
Showing 649–660 of 3610 questions
PUT generally replaces the target resource representation and is idempotent; PATCH applies partial modifications.
A safe method is intended not to change server state, while an idempotent method has the same intended effect when repeated.
Use status codes consistently: 200 for successful retrieval/action, 201 for creation, 204 for success without a body, 400 for malformed/invalid input, 401 for unauthenticated, 403 for forbidden, 404 for missing resources, 409 for conflicts, 422 for semantic validation where adopted, 429 for rate limits, and 5xx for server failures.
Use stable nouns for resources, plural collections where conventional, and nested paths only when the relationship is meaningful.
Offset pagination is simple but can become slow or inconsistent for large changing datasets.
Define an explicit allowlist of filter and sort fields, validate values, and parameterize database inputs.
Return a stable error schema with a machine-readable code, safe message, optional field details, and correlation ID.
Content negotiation lets clients express acceptable representations through headers such as Accept.
An ETag identifies a representation version.
For operations that clients may retry, accept an idempotency key and persist the key, request fingerprint, and outcome atomically.
HATEOAS exposes links or actions in resource representations so clients can discover available transitions.
Announce deprecation, measure client usage, provide a migration path, document the replacement, and set a communicated sunset date.