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

99
Views
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
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!