Question

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

A network automation script needs to issue an API request to a Cisco DNA Center endpoint to configure a global SNMP server setting. The requirement specifies that the request must create the SNMP resource at a specific URI if it does not exist, or completely replace the existing SNMP configuration at that URI if it does exist. Additionally, the operation must be idempotent so that running the script multiple times with the same payload produces the exact same state without side effects. Which HTTP verb must the script use to perform this action?

  1. PUTAnswer
  2. B
    POST
  3. C
    PATCH
  4. D
    GET

Answer

The HTTP PUT method should be used because it is an idempotent operation designed to create or completely replace a target resource at a specified URI.
HTTP PUT is used in RESTful APIs to create or completely replace a resource at a target URI. Because PUT is idempotent, submitting identical requests repeatedly will yield the exact same resource state on the target controller without creating duplicate objects.

Step-by-Step Solution

1
Identify the required operational characteristics
The operation must create or completely replace a resource representation at a specific URI and must be idempotent.
REST API architectural guidelines define specific HTTP verbs for different state mutation behaviors.
2
Evaluate the HTTP PUT verb properties
HTTP PUT maps to Create/Update in CRUD operations when acting on a specific URI, replacing existing data or creating it if absent, and is defined as idempotent.
Calling PUT multiple times with the exact same payload produces the same result on the target server state.
3
Distinguish PUT from POST and PATCH
POST is non-idempotent and creates subordinate resources, while PATCH applies partial updates to specific fields.
Only PUT satisfies both complete replacement/creation at a target URI and strict idempotency requirements.

Key Concept

HTTP Verbs and Idempotency in REST APIs
Rate this question