Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

799
Visualizações
Fast api shows 'msg': 'field required', 'type': 'value_error.missing'

Good evening everyone. I', trying to make a request to add new user to my database using Fast api. But when I try to to this through the python console app, Fast Api shows me this message: "{'detail': [{'loc': ['body', 'nickname'], 'msg': 'field required', 'type': 'value_error.missing'}, {'loc': ['body', 'password'], 'msg': 'field required', 'type': 'value_error.missing'}, {'loc': ['body', 'email'], 'msg': 'field required', 'type': 'value_error.missing'}]}"

But when I do this request in /docs everything is working!

Here is my pydantic model:

class GetUserModel(BaseModel):
    nickname: str
    password: str
    email: str

    class Config:
        orm_mode = True

Here is my handler:

@users_router.post("/users/", status_code=200)
def add_new_user(user: GetUserModel, session: Session = Depends(get_session)):
    user.password = bcrypt.hashpw(
        user.password.encode(),
        bcrypt.gensalt()
    )  # password hashing

    new_user = User(**user.dict())
    add(session, new_user)  # adding to database

And here I'm trying to make a request:

response = requests.post(
                    'http://127.0.0.1:8000/users/',
                    data={
                        "nickname": "1",
                        "password": "1",
                        "email": "1"
                    })
print(response.json())

If you know what can be the problem, please tell me, I would really appreciate it!

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda