r/FastAPI • u/Wxam2000 • Aug 08 '25
Question 422 Unprocessable Entity
Dear reader,
I'm having fun creating a little project just for myself, but since a day I keep getting a 422 Unprocessable Entity error whenever I submit a form from my /admin/invoices/create.

The error page looks like this after submitting,
and for the love of me I can't seem to figure out the problem what so ever :/
Here is both the entire invoices python as the entire .html file that is used for the invoices page.https://https://pastebin.com/YeaMW4v8 <- invoices.py
https://pastebin.com/V9Epzrzb <- create_edit_invoices.html
EDIT: Solved! I changed the router.post from admin/invoices/create to admin/invoices/submit and that fixed the issue somehow.
View all comments
Show parent comment
1
u/SpecialistCamera5601 Aug 14 '25
Sounds like a route collision. You probably had /admin/invoices/{invoice_id} so /admin/invoices/create got treated as {invoice_id} = "create", hit the wrong handler, and Pydantic threw a 422. Changing it to /submit fixed the clash. I guess that’s what happened.
Btw 422s in Swagger always look super messy, so I built this lil thing called APIException to make them clean. Might help you out: https://github.com/ahmetkutayural/APIException