API foundations

Inspect requests and responses

Use curl to see methods, URLs, headers, bodies, and status codes instead of debugging an API from rendered JSON alone.

8 minute lesson

~~~

A browser tab hides most of an HTTP exchange. API debugging starts by inspecting the complete request and response.

curl -i includes response headers. -v shows connection and request details. Use -X only when necessary; a request body option such as --json already selects POST.

curl -i http://localhost:3000/books
curl -i --json '{"title":"Dune","author":"Frank Herbert"}' http://localhost:3000/books

Read the exchange in order: resolved URL, request method and headers, response status, response headers, then body. A JSON-looking body does not prove success; a proxy can return an HTML error, a redirect, or a cached response with a surprising status. Use -i for contract evidence and add -v when connection, TLS, redirect, or request-header details matter.

The browser network panel adds browser-specific evidence such as preflight requests and blocked response access. The server may have processed a request even when browser JavaScript reports a CORS failure. Reproduce the HTTP request with curl, then compare the browser’s Origin and preflight headers before changing application logic.

Send one valid request and one request to a missing path. Save the exact status, content type, and body for each.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →