I have a POST request which have just a string parameter
[HttpPost]
public IHttpActionResult CheckMfaEnabled([FromBody]string userEmail)//
{
var isMfaEnabled = //use another service to return true/false
return Ok(isMfaEnabled);
}
and I call it like this
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://localhost:60099");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
StringContent content = new StringContent(JsonConvert.SerializeObject(userEmail), Encoding.UTF8, "application/json");
var response = client.PostAsync("api/MFA/CheckMfaEnabled", content).Result;
return response.IsSuccessStatusCode;
}
It gets me 404 not found Error , I guess something is wrong in my way of calling HTTPPOST. Can anyone please help me?