0

I'm trying to make a POST request with x-www-form-urlencoded, the backend is using .NET and I definetely need to POST in that way, because it is not working the request by sending a JSON. My component is the next one.

sendLead(model, API_ENDPOINT) {
const body = new URLSearchParams();
body.set('company_type', this.model.company_type);
body.set('user_id', this.model.user_id);
body.set('user_name', this.model.user_name);
body.set('user_email', this.model.user_email);
body.set('user_tel', this.model.user_tel);
body.set('user_company', this.model.user_company);
body.set('city', this.model.city);

const options = {
  headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')
};

this.http
  .post(this.API_ENDPOINT, body.toString(), options).subscribe();  }

By requesting the POST with Angular I get the following error

{successful_register: false, error: "'NoneType' object is not subscriptable"}

By requesting the POST with Postman I get the following answer

"{\"successful_register\": \"1\", \"error\": null}"

0 Answers0