Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

300
Views
Cómo publicar una solicitud de JSON en fastapi y recuperar todo el JSON en la función de publicación

Quiero pasar un objeto JSON a un backend fastapi. Esto es lo que estoy haciendo en la aplicación frontend:

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

Así es como se ve la API de back-end en fastapi:

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

Sin embargo, estoy viendo un error:

 json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

En su lugar, debe usar el parámetro json (que cambiará el Content-Type en el encabezado a application/json ), no data que se usan para enviar datos de formulario. Además, eche un vistazo a la documentación sobre cómo beneficiarse del uso de modelos Pydantic para cuerpos de solicitud.

 response = requests.post(api_url, json=data)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!