python
runtime_error
ai_generated
true
fastapi.exceptions.RequestValidationError: value is not a valid dict (type=type_error.dict)
ID: python/fastapi-form-data-required
80%Fix Rate
88%Confidence
0Evidence
2026-01-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 0.100.x | active | — | — | — |
| 0.110.x | active | — | — | — |
Root Cause
Sending form data but endpoint expects JSON, or vice versa.
generic中文
发送表单数据但端点期望 JSON,或反之。
Workarounds
-
95% success
from fastapi import Form @app.post('/login') async def login(username: str = Form(...), password: str = Form(...)): -
90% success
For JSON: `Content-Type: application/json`; for form: `application/x-www-form-urlencoded`.
Dead Ends
Common approaches that don't work:
-
60% fail
If server expects form, JSON still fails.
-
80% fail
Still expects JSON.