Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

303
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda