Soru

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

An automated provisioning script executes an HTTP request targeting a Cisco RESTCONF resource URI representing an interface configuration. The request payload includes only an updated description string. After execution, the interface description is updated, but all previously configured IP addressing and administrative state settings under that interface resource are completely cleared and reset to defaults. Which HTTP request method did the script use, and why did this data loss occur?

  1. HTTP PUT was used because it performs a complete replacement of the target resource, overwriting unreferenced fields with null or default values.Cevap
  2. B
    HTTP POST was used because it creates a new child resource and flushes all existing parent attributes at the specified endpoint.
  3. C
    HTTP PATCH was used because it applies partial updates but forces unreferenced parameters to revert to default state.
  4. D
    HTTP GET was used because retrieving resource state automatically clears unspecified configuration parameters.

Cevap

HTTP PUT was used because it performs a complete replacement of the target resource, overwriting unreferenced fields with null or default values.
In REST-based APIs (including Cisco RESTCONF and Cisco DNA Center APIs), HTTP PUT maps to replacing an existing resource in its entirety. When an API client sends an HTTP PUT request, the server expects a complete representation of the resource. If optional or unreferenced attributes (such as IP addressing or administrative status) are omitted from the PUT payload, the server replaces the current resource state with the new payload, causing omitted fields to be deleted or reset to default values. To selectively update only specific parameters while leaving unmentioned fields untouched, HTTP PATCH must be used.

Adım Adım Çözüm

1
Analyze the observed behavior during API execution
The target interface resource updated the specified attribute (description) but wiped out all unspecified attributes (IP address and administrative state).
This indicates full resource replacement rather than a selective partial modification.
2
Map HTTP verbs to their operational behaviors under RESTful APIs
HTTP PUT replaces the entire target resource data structure at the specified URI, whereas HTTP PATCH performs a partial update modifying only the fields present in the payload.
Omitting existing attributes in an HTTP PUT request payload causes the RESTful server to overwrite those missing attributes with default or null values.
3
Conclude the correct verb and root cause
The script erroneously issued an HTTP PUT request instead of an HTTP PATCH request.
To preserve unreferenced attributes while modifying only the description field, HTTP PATCH should have been used.

Anahtar Kavram

Operational differences between HTTP PUT (full resource replacement) and HTTP PATCH (partial resource modification) in REST-based network automation APIs.
Tahmini Süre:1m 30s
Bu soruyu puanla