FastAPI does not allow to send a "None" UploadFile #12040
-
Privileged issue
Issue ContentI have a POST method with FastAPI which has 2 params with UploadFile type. But one of them is required and one of them is Optional. When I send required param with None value, I got 422 error relating to "Field required". But if I send Optional param with None value, it's acceptable. My code is below: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
|
You don't need to use ellipsis with To fix your code you should remove ellipsis and use |
Beta Was this translation helpful? Give feedback.
I think the problem is that
requestsjust ignores the file parameter that isNoneand sends the request without it.You can use the code below to see the raw request, that is sent: