DevNet Associate (DEVASC) v1.0Understanding and Using APIsMedium
A network operations team is developing an automation script to provision new VLANs on multiple Cisco switches using an API. The API documentation states that the endpoint for creating VLANs is `/api/v1/devices/{device_id}/vlans` and accepts a JSON payload for VLAN configuration. Which type of OpenAPI parameter defines `{device_id}` in this URL path?
- ACookie parameter
- BQuery parameter
- CHeader parameter
- DPath parameter
Show answer & explanationAnswer & explanation
Correct answer: D. Path parameter
In OpenAPI Specification, curly braces `{}` within a URL path indicate a path parameter. These parameters are essential parts of the URL and identify a specific resource.
Why the other options are wrong
- A. Cookie parameters are sent as HTTP cookies, not within the URL path.
- B. Query parameters are appended to the URL after a '?' (e.g., `?key=value`).
- C. Header parameters are sent as HTTP headers, not part of the URL path.
OpenAPI Path Parameter
An OpenAPI path parameter is a variable part of the URL path, enclosed in curly braces, used to identify a specific resource or collection within the API.
- Part of the URL path.
- Enclosed in curly braces `{}`.
- Used to identify specific resources.
Memory trick: Path parameters map to locations in the URL.