1

My code:

@app.post('/create')
async def createUser(request: UserRequest, db: Session = Depends(get_db)):
      print(request)
      _user = crud.createUser(db, user_schema=request.parameter)    
      return _user

Schema:

class UserSchema(BaseModel):

# id: Optional[int] = None
      username: Optional[str] = None
      password: Optional[str] = None
      email: Optional[str] = None

      class Config:
            orm_mode = True
    
    
class UserRequest(BaseModel):
       parameter: UserSchema = Field(...)

The error:

"loc": "body"
"msg": "value is not a valid dict",
"type": "type_error.dict"
Chris
  • 18,724
  • 6
  • 46
  • 80
TASK
  • 69
  • 1
  • 1
  • 5
  • Related answers can be found [here](https://stackoverflow.com/a/74237131/17865804), [here](https://stackoverflow.com/a/71874694/17865804), as well as [here](https://stackoverflow.com/a/71471293/17865804) and [here](https://stackoverflow.com/a/71439821/17865804). – Chris Nov 14 '22 at 06:23
  • 3
    What was the HTTP request look like? – Spike Lee Nov 14 '22 at 06:32

0 Answers0