Persistent 422 Error with FastApi with an endpoint that accepts parameters and a file upload #10652
Unanswered
markjrouse
asked this question in
Questions
Replies: 2 comments 4 replies
-
Try changing your request to look more like the multipart upload described on this page. https://www.python-httpx.org/quickstart/ If that doesnt work copy the curl example from the swagger doc and paste it here so we can see what the request that works looks like. |
Beta Was this translation helpful? Give feedback.
3 replies
-
HI, Thanks! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First Check
Commit to Help
Example Code
Description
I have an endpoint defined for uploading a file, and accepting some parameters. Through the swagger interface this endpoint works perfectly. My 3 parameters are saved to my database, and my file is uploaded. However, creating a test, to try and replicate posting to this endpoint a file, and 3 parameters, results in FastAPI returning a 422 error with {"detail":[{"loc":["body","file"],"msg":"field required","type":"value_error.missing"}]}. I'm guessing I'm doing something wrong, but can't figure where I'm going wrong.
Operating System
macOS
Operating System Details
No response
FastAPI Version
0.103.1
Pydantic Version
1.10.8
Python Version
3.11.6
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions