Pcornel
Browse topics
Options
Recent
Favorites
Networking · Technical reference

HTTP & REST API Fundamentals

Direct answer

HTTP REST APIs expose resources at URLs and use methods to act on them: GET reads, POST creates, PUT/PATCH update, DELETE removes. Status codes report the result (2xx success, 4xx client error, 5xx server error); GET, PUT and DELETE are idempotent.

When to use this

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.

First 30 seconds

Choose method (GET, POST, PUT, PATCH, DELETE) → set headers (Content-Type, Accept, auth) → send request → read status code → parse body → handle errors.

Operational verification

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

Failure signatureREST API call returns 401 or 403

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
Platform / version applicability
Cisco IOS / IOS XE
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformCisco IOS / IOS XE
Scope / prerequisiteUse 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 …
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

4 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 references

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.

observation · 1
Command lookup Jump straight to Cisco syntax
Key points

HTTP success describes the response semantics for a request. It is not independent proof of correct permissions, durable network configuration or service behavior.

Key checks

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

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.

ReferenceWhy it matters1 section · depth on demand

Why it matters

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

Programmability separates data representation/model from transport and authorization. JSON/YAML encode data, YANG describes structured network data, REST/RESTCONF/API calls carry requests, and authentication/authorization control whether an operation is accepted.

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

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

HTTP semantics for REST APIs

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

MethodSafeIdempotentTypical API use
GETYesYesRead devices, interfaces, status
POSTNoNoCreate resources, start jobs, call RPCs
PUTNoYesReplace a resource completely
PATCHNoNot guaranteedPartial update (RFC 5789)
DELETENoYesRemove a resource

Status codes and what to do (RFC 9110)

CodeMeaningScript action
200 / 201 / 204OK / Created / No contentContinue
400Bad requestFix the payload; don't retry unchanged
401Not authenticated (challenge)Get a new token, then retry once
403Authenticated but not allowedCheck roles; don't retry
404Not foundCheck the URI or object ID
405Method not allowed for this resourceUse the documented method
409Conflict with current stateRe-read state, then decide
415Unsupported media typeSet the correct Content-Type
503Service unavailableRetry 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
Technical examples

Configuration & expected output

Concrete examples are shown only when the stored reference contains an actual configuration or output shape for this Topic.

Expected output

HTTP client (curl)curl -i -H "Accept: application/json" https://api.example.net/v1/interfaces/Gi1

Expected 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.
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docCisco IOS / IOS XE Current documentation reviewed 2026-09-14

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%
Terminology layer

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.

Depth when you need it

Deep reference

Design & tradeoffs

ENCOR design tradeoffs

API automation must validate responses and be safe to retry based on method/action semantics.

Confirmation

Confirm action

Continue?