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

302
Visualizações
How to post request JSON to fastapi, and retrieve whole JSON in the post function

I want to pass a JSON object to a fastapi backend. Here is what I am doing in the frontend app:

data = {'labels': labels, 'sequences': sequences}
response = requests.post(api_url, data = data)

Here is how the backend API looks like in fastapi:

@app.post("/api/zero-shot/")
async def Zero_Shot_Classification(request: Request):
    data = await request.json()

However, I am seeing an error:

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You should use json parameter instead (which will change the Content-Type in the header to application/json), not data which is used for sending form data. Also, please have a look at the documentation on how to benefit from using Pydantic models for request bodies.

response = requests.post(api_url, json=data)
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