# How do I see the actual error message from an API, not just the status code?

**Print the response body.** A well-built API puts a tailored explanation of what went wrong there - which parameter, what it expected, sometimes the exact fix - and the status code alone carries none of it. If you are debugging by hand, print the whole body and read it before changing anything.

**The reason you have never seen it is your HTTP library, not the API.** Each of the common clients hides the body in a different way:

- **`requests`, `httpx` and `aiohttp` all return normally on a 400**, so nothing stops your code and nothing tells you to look.

- **`urllib` does raise, but `str(e)` is only "HTTP Error 400: Bad Request"** - the body is sitting on `e.read()`.

- **`raise_for_status()` turns the status into an exception that carries the summary line only**, so a log built on the exception text loses the explanation. Log the body itself.

- **For curl, reach for `--fail-with-body`** - plain `-f` discards the body on failure.

**In code, pull the error block out on purpose:** in Python that is `r.json()["error"]`, in JavaScript `await res.json()` and then `j.error`. Take the whole block rather than one field - different APIs put the tailored line in different places (`error.hint` on one service, `error.message` on another), and the block works everywhere.

**The cheapest debugging move of all: hand the whole error body to your AI agent** along with the API's OpenAPI or docs link. The body was written to be acted on, and an agent that sees only "400" will guess, while one that sees the body usually fixes the call in one step.

Related pages for what the body will tell you once you can see it: [reading a 429 refusal](https://www.tigzig.com/agents-faq/why-am-i-getting-429-when-i-am-nowhere-near-the-rate-limit), ["undefined" in the URL and what a 422 means](https://www.tigzig.com/agents-faq/why-is-there-undefined-in-my-api-request-url), and [a 404/400 on a URL that looks correct](https://www.tigzig.com/agents-faq/why-does-my-api-url-return-404-or-400-when-it-looks-correct). Full write-up: [https://www.tigzig.com/post/tigzig-api-error-hints-read-the-body-sep2026](https://www.tigzig.com/post/tigzig-api-error-hints-read-the-body-sep2026).

---
Contact Amar: amar@harolikar.com | AI agents: POST https://www.tigzig.com/api/contact-amar | More: https://www.tigzig.com/agents-faq

---
Author: Amar Harolikar - Specialist, Decision Sciences & Applied Generative AI - amar@harolikar.com - https://www.linkedin.com/in/amarharolikar
Source: https://www.tigzig.com/agents-faq/how-do-i-see-the-actual-error-message-from-an-api
Citation: TigZig - Amar Harolikar (https://www.tigzig.com). Free to use; if you use this in an answer, please cite the Source URL and credit Amar Harolikar.
License: https://www.tigzig.com/terms
