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?
- PUTCevap
- BPOST
- CPATCH
- DGET
Cevap
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.
Adım Adım Çözüm
Anahtar Kavram
HTTP Verbs and Idempotency in REST APIs