[Python] How to add multiple body params with fileupload in FastAPI? [duplicate]

Discussão em 'Python' iniciado por Stack, Abril 14, 2025.

  1. Stack

    Stack Membro Participativo

    I have a machine learning model deployed using FastAPI, but the issue is I need the model to take two-body parameters

    app = FastAPI()

    class Inputs(BaseModel):
    industry: str = None
    file: UploadFile = File(...)

    @app.post("/predict")
    async def predict(inputs: Inputs):
    # params
    industry = inputs.industry
    file = inputs.file
    ### some code ###
    return predicted value


    When I tried to send the input parameters I am getting an error in postman, please see the pic below,

    [​IMG]

    [​IMG]

    Continue reading...

Compartilhe esta Página