Question

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

A network automation engineer attempts to create a new syslog host entry on a Cisco router using RESTCONF. The engineer sends an HTTP POST request to the parent container endpoint `/restconf/data/Cisco-IOS-XE-native:native/logging/host`. The API gateway responds with an HTTP status code of `409 Conflict` because a syslog host entry with the specified IP address already exists. Which HTTP request method and URI target combination must the engineer use to completely replace the existing syslog host entry configuration?

  1. Issue an HTTP PUT request targeting the specific resource URI `/restconf/data/Cisco-IOS-XE-native:native/logging/host/name=192.168.1.50` with the complete resource payload.Answer
  2. B
    Issue an HTTP POST request targeting the specific resource URI `/restconf/data/Cisco-IOS-XE-native:native/logging/host/name=192.168.1.50` with only the modified parameters.
  3. C
    Issue an HTTP GET request containing a request body with the updated configuration fields to the container URI `/restconf/data/Cisco-IOS-XE-native:native/logging/host`.
  4. D
    Issue an HTTP OPTIONS request to the root datastore URI `/restconf/data` to automatically clear and re-create the logging configuration.

Answer

Issue an HTTP PUT request targeting the specific resource URI `/restconf/data/Cisco-IOS-XE-native:native/logging/host/name=192.168.1.50` with the complete resource payload.
In REST-based APIs such as RESTCONF, HTTP POST maps to Create operations under a collection URI. When a resource already exists, POST yields a 409 Conflict error. To update or completely replace an existing targeted resource, the API client must send an HTTP PUT request directly to the URI identifying that specific resource instance.

Step-by-Step Solution

1
Analyze the REST API operation and error response
The HTTP 409 Conflict status indicates that an HTTP POST request attempted to create a resource that already exists at the target location.
HTTP POST is mapped to the Create operation in CRUD and is submitted to a parent/collection endpoint. It fails if the item already exists and duplicate creation is prohibited.
2
Determine the appropriate HTTP verb for updating/replacing an existing resource
HTTP PUT is the correct verb for replacing an existing data node representation in REST APIs (Update/Replace in CRUD).
PUT is idempotent and is used to create or replace a resource at a specified, explicit URI.
3
Identify the proper URI target structure for RESTCONF resource modification
The request must target the specific item URI key (`.../logging/host/name=192.168.1.50`) rather than the broad parent container URI.
To modify a specific instance in a list, RESTCONF requires appending the key identifier to the URI path.

Key Concept

REST API CRUD Mapping (HTTP PUT vs POST)
Estimated Time:2m 0s
Rate this question