curl Favorites

API Authentication

ISE ERS API

# ISE ERS API - basic authentication
curl -sk -u "${ISE_USER}:${ISE_PASS}" \
  -H "Accept: application/json" \
  "https://${ISE_HOST}/ers/config/endpoint" | jq '.SearchResult.total'

Vault API

# Vault API with token
curl -sk -H "X-Vault-Token: ${VAULT_TOKEN}" \
  "${VAULT_ADDR}/v1/pki_int/ca/pem"

Wazuh API with JWT

# Wazuh API with JWT
TOKEN=$(curl -sk -u "${WAZUH_USER}:${WAZUH_PASS}" \
  -X POST "${WAZUH_API_URL}/security/user/authenticate" | jq -r '.data.token')
curl -sk -H "Authorization: Bearer $TOKEN" "${WAZUH_API_URL}/agents?limit=500"

Debugging

HTTP Timing Debug

# Full HTTP debug - headers, timing, response
curl -sk -w '\n---TIMING---\nDNS: %{time_namelookup}s\nConnect: %{time_connect}s\nTLS: %{time_appconnect}s\nTotal: %{time_total}s\nHTTP: %{http_code}\n' \
  -o /dev/null \
  "https://grafana.inside.domusdigitalis.dev"

Certificate Chain

# Fetch and display certificate chain
echo | openssl s_client -connect grafana.inside.domusdigitalis.dev:443 -servername grafana.inside.domusdigitalis.dev 2>/dev/null | \
  openssl x509 -noout -subject -issuer -dates

POST Operations

POST JSON with Heredoc

# POST JSON with heredoc
curl -sk -X POST -H "Content-Type: application/json" \
  -u "${ISE_USER}:${ISE_PASS}" \
  "https://${ISE_HOST}/ers/config/endpoint" \
  -d @- <<'EOF'
{
  "ERSEndPoint": {
    "mac": "AA:BB:CC:DD:EE:FF",
    "groupId": "aa0e8b20-8bff-11e6-996c-525400b48521",
    "staticGroupAssignment": true
  }
}
EOF

Quick Reference

Flag Purpose

-sS

Silent but show errors

-k

Skip TLS verification

-L

Follow redirects

-o /dev/null -w "%{http_code}"

Status code only

-H "Accept: application/json"

Set header

-d @file.json

POST file contents

File Downloads

Cisco Exam PDF Workflow

Download exam topics, extract text, preview structure:

# Download exam topics PDF
curl -L -o /tmp/exam-topics.pdf \
  "https://learningcontent.cisco.com/documents/marketing/exam-topics/200-901-CCNAAUTO_v.1.1.pdf"
# Extract text from PDF
pdftotext /tmp/exam-topics.pdf /tmp/exam-topics.txt
# Preview first 30 lines to understand structure
awk 'NR>=1 && NR<=30' /tmp/exam-topics.txt

# Preview specific range
awk 'NR>=30 && NR<=80' /tmp/exam-topics.txt

See DevNet Certification for usage example.