-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Closed
Labels
Description
First Check
- I added a very descriptive title to this issue.
- I used the GitHub search to find a similar issue and didn't find it.
- I searched the FastAPI documentation, with the integrated search.
- I already searched in Google "How to X in FastAPI" and didn't find any information.
- I already read and followed all the tutorial in the docs and didn't find an answer.
- I already checked if it is not related to FastAPI but to Pydantic.
- I already checked if it is not related to FastAPI but to Swagger UI.
- I already checked if it is not related to FastAPI but to ReDoc.
Commit to Help
- I commit to help with one of those options 👆
Example Code
@router.post('/add',status_code=200)
async def add(values: List[float] = Form(...), file: UploadFile = File(...)):
...Description
Given a post route with a file and array of floats when using the swagger interface '/docs' and posting a file and an array with a SINGLE item everything works. Posting an file and an array with MORE then one value fastAPI returns 422 Unprocessable Entity.
Working CURL request:
curl -X 'POST' \
'http://localhost:8000/add' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@image.jpg;type=image/jpeg' \
-F 'value=1' // <-------------------Failing CURL request:
curl -X 'POST' \
'http://localhost:8000/add' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@image.jpg;type=image/jpeg' \
-F 'value=1,2' // <-------------------Operating System
Linux
Operating System Details
No response
FastAPI Version
0.74.1
Python Version
3.9.10
Additional Context
No response