Cisco CCNA (200-301)Automation and ProgrammabilityMedium
An automation engineer is writing a script that calls a REST API to update the description field on an existing interface object without replacing the entire resource. Which HTTP method is most appropriate for a partial update?
- APOST
- BPUT
- CDELETE
- DPATCH
Show answer & explanationAnswer & explanation
Correct answer: D. PATCH
PATCH is designed for partial modifications to an existing resource, updating only the specified fields. PUT typically replaces the entire resource, POST creates a new resource, and DELETE removes one.
Why the other options are wrong
- A. POST is generally used to create a new resource, not modify part of an existing one.
- B. PUT usually replaces the full resource representation, requiring all fields to be resent.
- C. DELETE removes a resource entirely, which is not the goal here.
REST HTTP Methods
REST APIs use standard HTTP verbs to perform CRUD operations: GET (read), POST (create), PUT (full update/replace), PATCH (partial update), DELETE (remove).
- GET is safe and idempotent
- PUT is idempotent, replaces whole resource
- PATCH modifies only specified fields, not necessarily idempotent
Memory trick: POST creates, GET reads, PUT replaces, PATCH patches, DELETE destroys.