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

96
Vistas
Content of body has been changed when send a HTTP Post request from Angular front-end to server side

In server side I used FastAPI framework to create API.

In Angular , I created a service to send a HTTP Post request like the following:

 runTest(
    questionId: string,
    language_name: string,
    code: string
  ): Observable<any> {
    console.log(code)
    //use http params for query parameters
    
    let params = new HttpParams().set('language',language_name);
    
    let apiUrl = `${this.BASE_URL}/question/${questionId}/run_test` ;
    return this.http.post<any>(apiUrl,code , { params: params })
  }

I place code as body of HTTP Post request. Before I send request I console.log(code) to check content of code . The content of code is type of string and it looks like the following:

def add(a:float,b:float) -> float:
    sum = a+b
    return sum

In Server side the corresponding API that I wrote by FastAPI framework like the following:

@router.post("/{id}/run_test")
async def run_test(id:str=Path(...), language: str = Query(...), code: str = Body(...)):
    
    print(code)

But code I got when print(code) is:

def add(a:float,b:float) -> float:
    tong = a+b
        return tong

As you can see,the content of code when I sent in front-end and the content of code when I got in server side is different .

I don't know what happens during process of send HTTP Post request to server side.Please help me. And I'm sorry for my English .

about 4 years ago · Juan Pablo Isaza
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