I'm using FastAPI and I'm trying to send a JSON array of JSON objects to my post endpoint, in the body. My endpoint is defined as:
@router.post("/create_mails")
def create_mails(notas: List[schemas.Nota], db: Session = Depends(get_db)):
My body in Postman looks like:
{
"notas": [{"a":"1","b":"2","c":"3","d":"4"},
{"a":"1","b":"2","c":"3","d":"4"}]
}
However, I keep getting the 422 unprocessable entity error from FastAPI, with the error detail:
value is not a valid list
I also tested it with a modified endpoint:
@router.post("/create_mails")
def create_mails(notas: List[str] = Body([]), db: Session = Depends(get_db)):
and with a simple string array, but the same error is returned.
Am I missing FastAPI's definition of a valid list?