Question

Difficulty: MediumCharacteristics of REST-Based APIs (CRUD, HTTP Verbs, Data Formats)

A network engineer needs to update the description field of an existing interface resource on a router using a RESTful API. The requirement specifies that only the description attribute should be modified, while leaving all other existing configuration parameters for that interface unchanged on the server. Which HTTP verb and payload strategy should be selected to perform this operation?

  1. HTTP PATCH with a payload containing only the updated description attributeAnswer
  2. B
    HTTP PUT with a payload containing only the updated description attribute
  3. C
    HTTP POST with a payload containing the interface identifier and updated description
  4. D
    HTTP GET with the updated description parameters appended as query strings

Answer

Use HTTP PATCH with a payload containing only the modified description attribute.
HTTP PATCH is specifically designed for partial modifications to an existing resource. When an API receives an HTTP PATCH request, it applies changes only to the keys included in the request body, leaving all unmentioned resource attributes intact.

Step-by-Step Solution

1
Identify the CRUD operation required for modifying an existing resource.
The operation requires an Update action on specific fields of an existing resource.
The requirement asks to update an existing configuration rather than creating a new resource or reading existing data.
2
Distinguish between complete replacement (PUT) and partial modification (PATCH).
HTTP PATCH is designed for partial updates, whereas HTTP PUT performs full resource replacement.
Sending a partial payload with HTTP PUT will overwrite omitted attributes with null or default values. HTTP PATCH modifies only the specified attributes.

Key Concept

HTTP Verbs and Resource Mutation (PATCH vs. PUT)
Rate this question