I am new to Angular4
and in a situation to deliver the stuff quickly so have no time to learn it thoroughly so pardon if my question seems childish:
From my Asp.Net Web API
I have Confirmemail API
which has to be called from Angular4 application, looks like this:
Asp.net WebApi:
[HttpPost]
public async Task<object>ConfirmEmail([FromBody] string userid,[FromBody] string code)
{
}
In Angular4 Service API:
ConfirmEmail(userid,code)
{
let url =`api/account/ConfirmEmail`;
let data= `userid=${userid}&code=${code}`;
console.log(data);
return this.http.post(url,data);
}
Here, I checked in console.log the data is coming properly, but at the webapi side I am finding these strings null. I tried removing [FromBody] but it didn't worked with me.
I am really clueless what is missing, it is almost one day preparing all these things but have not got any success. Do you guys have any workaround?
For
post
data to yourAPI
from angular app try this in angular:and in your
API
for receive your request body and deserialize this:For send your data in url you should use http
get
method like this:Angular:
Web API:
You can make an object of both userid and code and convert to string using
JSON.stringify(data);
and access it as