-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
from fastapi import UploadFile
from typing import Union
@router.post("/",
summary="Store pdf in database",
description="Store pdf in database and return pdf",
status_code=status.HTTP_201_CREATED,
responses={status.HTTP_400_BAD_REQUEST: {"model": ResponseMessage},
status.HTTP_401_UNAUTHORIZED: {"model": ResponseMessage},
status.HTTP_422_UNPROCESSABLE_ENTITY: {"model": ResponseMessage},
status.HTTP_500_INTERNAL_SERVER_ERROR: {"model": ResponseMessage}})
async def create(self, slip_code: str, payload: PDFPrinting, upload_file: Union[UploadFile, None] = None, upload_file1: Union[UploadFile, None] = None, tax_year: int = TAX_YEAR_VALIDATION_RULE) -> ResponseMessage:Description
- When I am using fastapi uploadfile to upload pdf file and request payload in query parameter then it gives us 422 error with message("Expected UploadFile, received: <class 'str'>") , I want to upload files and also want to send request payload as I shown in picture request payload. Why it is sending this error shown in error_face picture. please response.
Operating System
Windows
Operating System Details
window 11
FastAPI Version
fastapi==0.78.0
Python Version
3.9.9
Additional Context
No response