Soru

Zorluk: OrtaCharacteristics of REST-Based APIs (CRUD, HTTP Verbs, Data Formats)

A network automation workflow uses RESTCONF to manage interface configurations on Cisco IOS XE routers. An engineer sends an HTTP PUT request to the URI endpoint of an existing interface resource (`.../ietf-interfaces:interfaces/interface=GigabitEthernet1`). The JSON payload included in the request contains only the updated `description` attribute and omits previously configured child attributes such as `ip` and `enabled`. Which outcome will occur on the target device when this request is processed?

  1. The interface description is updated, but any omitted attributes, such as the IP address configuration, are cleared or reset to their default values.Cevap
  2. B
    The interface description is updated while all omitted attributes remain untouched on the device.
  3. C
    The API server rejects the call with an HTTP 405 status code because modifying an existing resource requires HTTP POST.
  4. D
    A new secondary interface configuration object is created under the parent container without altering the existing interface.

Cevap

The interface description is updated, but any omitted attributes, such as the IP address configuration, are cleared or reset to their default values.
In REST-based APIs, HTTP PUT is defined as a full replacement operation (Update/Replace). When sending a PUT request to an existing resource URI, the server overwrites the entire target resource with the data provided in the request body. Any attributes omitted from the JSON payload will be removed or reset to default state. If partial updates are intended without affecting existing unmentioned attributes, HTTP PATCH must be used instead.

Adım Adım Çözüm

1
Identify the HTTP verb used in the REST API request.
The request utilizes the HTTP PUT method targeted at an existing resource endpoint.
Understanding the operational contract of HTTP verbs is critical for RESTful API interactions.
2
Distinguish between HTTP PUT and HTTP PATCH resource modifications.
HTTP PUT specifies a complete resource replacement, while HTTP PATCH specifies a partial modification.
Because the request uses PUT, any field not explicitly included in the request payload will be deleted or reset to default settings upon resource replacement.

Anahtar Kavram

HTTP PUT vs PATCH Operational Differences in REST APIs
Bu soruyu puanla