Use it when you call a device or controller API for the first time, or when a call fails and you need to tell from the method and status code whose problem it is.
HTTP & REST API Fundamentals
URL and method chosen → headers set (Accept, Content-Type, Authorization) → request sent over HTTPS → status code class (2xx, 4xx, 5xx) → body parsed → GET again to confirm a change
Requests fail with 401 Unauthorized or 403 Forbidden although the endpoint is correct.
Possible stored cause: 401: the token or credentials are missing, wrong or expired. 403: the account is authenticated but lacks permission for that resource.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Requests fail with 401 Unauthorized or 403 Forbidden although the endpoint is correct.
Step 1 Verification & evidence Verify boundary
Inspect method, URI, request body, response status, headers and returned JSON.
Step 2 Common failure modes Narrow the fault
401/403 auth, 404 URI, 405 method, 400 schema/body, 409 conflict or blindly treating any 2xx/JSON as success.
Step 3 Troubleshooting workflow Narrow the fault
1. Define the exact symptom and affected scope.
2. Verify prerequisite transport/interface state.
3. Collect the most direct protocol/policy evidence.
4. Compare observed state with intended state.
5. Change one cause at a time and verify end to end.
Focus for this topic: 401/403 auth, 404 URI, 405 method, 400 schema/body, 409 conflict or blindly treating any 2xx/JSON as success.
Step 4 Common mistakes Narrow the fault
- Using GET to change data.
- Ignoring 4xx/5xx responses.
- Disabling TLS verification to get past certificate errors.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
HTTP success describes the response semantics for a request. It is not independent proof of correct permissions, durable network configuration or service behavior.
curl -i -H "Accept: application/json" https://host/api/resource → status line, headers and body. After a POST, PUT or PATCH, GET the resource again to confirm the change. 4xx = fix the request; 5xx = problem on the server.
ReferenceWhat it is3 sections · depth on demand
Direct Answer
HTTP & REST API Fundamentals owns generic resource, method, status-code, header and idempotency semantics. RESTCONF adds a YANG-specific protocol contract and has its own canonical reference.
Scope and canonical references
Use RESTCONF for RESTCONF-specific paths, methods and examples; REST API Security for security controls. A generic REST API may use different authentication and payload conventions from IOS / IOS XE RESTCONF.
Concept overview
Resources, URIs, methods, status codes, headers, authentication and idempotency concepts.
Key ideas: REST-style APIs expose resources over HTTP. GET reads; POST commonly creates/actions; PUT/PATCH update semantics differ; DELETE removes when supported.
ReferenceHow it works2 sections · depth on demand
How it works
Mechanism, scope & boundaries
API-based network automation has four distinct layers: transport/session, identity/authorization, resource/method semantics and structured data/model validation. JSON is a representation format; it is not the API, model or guarantee that the requested network state is valid.
ReferenceImportant terms & boundaries4 sections · depth on demand
Official Sources
Important terms and limits
Key terms: endpoint/resource, HTTP method, status code, header, payload, JSON, YANG, RESTCONF, authentication, authorization, idempotency and schema/model.
Proof Boundaries
HTTP success describes the response semantics for a request. It is not independent proof of correct permissions, durable network configuration or service behavior.
In depth
REST APIs are HTTP, so their behaviour follows HTTP semantics. RFC 9110 defines the methods:
- GET: requests the current representation of a resource.
- POST: asks the resource to process the enclosed data, often creating something.
- PUT: creates or replaces the target resource.
- DELETE: removes the association between the URI and the resource.
GET, HEAD, OPTIONS and TRACE are safe. PUT, DELETE and all safe methods are idempotent, so repeating them has the same intended effect as sending them once. 401 challenges for credentials, while 403 means valid credentials still don't grant access.
Methods in API work
| Method | Safe | Idempotent | Typical API use |
|---|---|---|---|
| GET | Yes | Yes | Read devices, interfaces, status |
| POST | No | No | Create resources, start jobs, call RPCs |
| PUT | No | Yes | Replace a resource completely |
| PATCH | No | Not guaranteed | Partial update (RFC 5789) |
| DELETE | No | Yes | Remove a resource |
Status codes and what to do (RFC 9110)
| Code | Meaning | Script action |
|---|---|---|
| 200 / 201 / 204 | OK / Created / No content | Continue |
| 400 | Bad request | Fix the payload; don't retry unchanged |
| 401 | Not authenticated (challenge) | Get a new token, then retry once |
| 403 | Authenticated but not allowed | Check roles; don't retry |
| 404 | Not found | Check the URI or object ID |
| 405 | Method not allowed for this resource | Use the documented method |
| 409 | Conflict with current state | Re-read state, then decide |
| 415 | Unsupported media type | Set the correct Content-Type |
| 503 | Service unavailable | Retry after the Retry-After time |
dev$ curl -s -o /dev/null -w "%{http_code}\n" https://ctrl.example.net/api/v1/devices
401
dev$ curl -s -H "Authorization: Bearer $TOKEN" -H "Accept: application/json" https://ctrl.example.net/api/v1/devices | jq length
dev$ curl -s -X PUT -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d @vlan130.json https://ctrl.example.net/api/v1/vlans/130 -w "%{http_code}\n"
dev$ python3 - <<'PY'
import requests
r = requests.get("https://ctrl.example.net/api/v1/devices",
headers={"Authorization": "Bearer <token>"}, timeout=10)
r.raise_for_status()
print(len(r.json()))
PY
Idempotency in automation
Because PUT and DELETE are idempotent, a script that times out can safely send them again. POST usually isn't, so retrying a POST can create duplicates. Check whether the object exists before re-sending.
Documented example, not captured output.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Configuration & expected output
Concrete examples are shown only when the stored reference contains an actual configuration or output shape for this Topic.
Expected output
curl -i -H "Accept: application/json" https://api.example.net/v1/interfaces/Gi1Expected state: Status 200 and a JSON body.
HTTP/1.1 200 OK
Content-Type: application/json
{"name": "GigabitEthernet1", "enabled": true}
! Illustrative output, not captured Evidence.The status line gives the result class, `Content-Type` tells how to parse the body, and the body is the resource. 404 would mean the URL does not name an existing resource; 401/403 an identity or permission problem.Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Automation and Artificial Intelligence → HTTP & REST API Fundamentals. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.cisco.com/c/en/us/support/ios-nx-os-software/ios-xe-17/series.html · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Deep reference
Design & tradeoffs
ENCOR design tradeoffs
API automation must validate responses and be safe to retry based on method/action semantics.