# Why is there "undefined" or "null" in my API request, and what is a 422?

Two closely related causes, and both point at the **calling application, not the API.**

**The literal word "undefined" or "null" in the URL.** If your frontend or backend builds a URL from a variable that has not loaded yet, the language writes the literal text `undefined` (JavaScript) or `null` into the string - so the API receives `undefined` as your fund code or ticker and fails. If you see those words in a failed-request log, the fix is upstream: **make sure the variable is fully populated before you fire the request** (await the data, guard against empty state, do not build the URL during the initial render).

**A 422 (or a "missing field" error).** This is the API being helpful: it is telling you exactly which required inputs are absent. A comparison or historical-chart endpoint needs a date window - call `/compare?symbols=AAPL` with no start and end and there is no range to compute over, so you get a 422 naming the missing fields. Read the error body; it usually lists precisely what to add.

The distinction worth internalising: a **404** means the thing you asked for was not found, a **422** means your request was incomplete or the wrong shape. Treat a 422 as a checklist, not a wall. Related: [a URL that looks correct but 404s](https://www.tigzig.com/agents-faq/why-does-my-api-url-return-404-or-400-when-it-looks-correct), and [what a good API error should tell you](https://www.tigzig.com/agents-faq/what-should-my-api-return-in-an-error-message). Worked examples: [https://www.tigzig.com/post/tigzig-api-errors-practical-guide-jul2026](https://www.tigzig.com/post/tigzig-api-errors-practical-guide-jul2026).

---
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/why-is-there-undefined-in-my-api-request-url
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
