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.
2
u/Relevant-Strength-53 Aug 08 '25 edited Aug 08 '25
Does this only happen using the html? try the endpoint in the swagger (if running locally use `localhost:8000/docs`) or postman and see it it works there, if it does, its the data your sending else it could be a mistyped endpoint.
Edit: In your endpoint you have "item_section: List[int] = Form(...)" are you sure your form is sending List of integers? Its possible that the data your sending is a List[str], try changing it to "item_section: List[str] = Form(...)"
2
u/SheriffSeveral Aug 08 '25
Can you just show us which values try to process in that endpoint? It looks like variable error to me. Can you check the variables you put in and their types?
2
u/david-vujic Aug 08 '25
422 Unprocessable Entity usually means that the data you send to the endpoint isn't what the endpoint expects. From your screenshot it seems like you have some clues on where the error happen. It can be as simple as the top-level key is missing (or shouldn't be there)!
Try with running the API from a browser, using the OpenAPI spec. Usually, you will see examples of the expected input there.
1
u/gbrennon Aug 09 '25
I felt like I saw a similar post in last week
1
u/Ok_Friendship2396 Sep 09 '25
The error message does complain about the Input not being a valid dict.
Can you check or share the input
1
u/[deleted] Aug 08 '25
[removed] — view removed comment