简体   繁体   中英

How to add = to request body to call rest api

I've figured out that when calling my API from Angular, the API process inserts a blank row in the database. I made testing with Fiddler and the local API and I was able to insert successfully a row in DB.

I had to add a '=' at the beginning of the JSON (request body) in Fiddler and everything worked as expected.

FiddlerView

My question would be, how can I add the '=' to the request body from Angular to have this working.

The code from my service.ts

Service.ts

Any help would be appreciated... Thanks in advance...

The problem is your content type. You are sending a JSON string in the request body, but you are identifying the content type as "application/x-www-form-urlencoded". You need to change your Content-Type header value to "application/json".

Do not use the "=" in the request body, as it is not valid JSON.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM