[Python] Input should be a valid list

Discussão em 'Python' iniciado por Stack, Setembro 30, 2024.

  1. Stack

    Stack Membro Participativo

    I am trying to filter objects by body parameters. My code:

    @app.post("/counters/")
    def list_counters(project_names: List[str], db: Session = Depends(get_db)):
    """ Get project by name"""
    query = db.query(models.Project).filter(models.Project.name.in_(project_names)).all()


    return {"message": ""}


    My request POST

    {
    "project_names": ["as"]
    }


    I see this error:

    {
    "detail": [
    {
    "type": "list_type",
    "loc": [
    "body"
    ],
    "msg": "Input should be a valid list",
    "input": {
    "project_names": [
    "as"
    ]
    }
    }
    ]
    }

    Continue reading...

Compartilhe esta Página