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

597
Visualizações
Errror parsing data in python FastAPI

I'm learning to use FastAPI, and I'm getting this error over and over again while implementing a simple API and I've not being able to figure out why

"detail": "There was an error parsing the body"

This happends me on this two endpoints:

Full code: Code Repository

snippet:

app_v1 = FastAPI(root_path='/v1')

# JWT Token request
@app_v1.post('/token')
async def login_access_token(form_data: OAuth2PasswordRequestForm = Depends()):
    jwt_user_dict = {"username": form_data.username, "password": form_data.password}
    jwt_user = JWTUser(**jwt_user_dict)
    user = authenticate_user(jwt_user)
    if user is None:
        return HTTP_401_UNAUTHORIZED
    jwt_token = create_jwt_token(user)
    return {"token": jwt_token}

request:

enter image description here

enter image description here

@app_v1.post("/user/photo")
async def update_photo(response: Response, profile_photo: bytes = File(...)):
    response.headers['x-file-size'] = str(len(profile_photo))
    response.set_cookie(key='cookie-api', value="test")
    return {"profile photo size": len(profile_photo)}

request: enter image description here

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I acomplished to figure out, it was because when FastAPI was installed, it didn't install python-multipart, so with this package missing everything that needs multipart falls

After installing it works fine

Thanks

over 4 years ago · Santiago Trujillo Relatório

0

The problem with the first request is that you should be sending username and password in a form-data. Instead of x-www-form-urlencoded, use form-data and you should be fine.

enter image description here

I can't see the problem with the second one. Can you try using Swagger interface and see if the same happens there?

over 4 years ago · Santiago Trujillo Relatório
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