http-status-code-422

File upload using FastAPI returns error 422

File upload using FastAPI returns error 422 Question: I am using the example from the official documentation: https://fastapi.tiangolo.com/tutorial/request-files/#import-file Server code: @app.post("/uploadfile") async def create_upload_file(data: UploadFile = File(…)): print("> uploaded file:",data.filename) return {"filename": data.filename} Client code: files = {‘upload_file’: open(‘config.txt’, ‘rb’)} resp = requests.post( url = URL, files = files) print(resp.json()) The problem is that the …

Total answers: 2

FastApi: 422 Unprocessable Entity

FastApi: 422 Unprocessable Entity Question: I’m getting this error while trying to accept a pedantic model. After debugging for quite some time I believe the problem is with accepting CodeCreate Pydantic model class BaseCode(BaseModel): index: Optional[int] = Field(None) email: EmailStr gen_time: datetime expire_time: datetime class CodeCreate(BaseCode): code: int used_time: Optional[datetime] = Field(None) class Config: orm_mode …

Total answers: 5