0
調用我有有隻是一個字符串參數HTTPPOST請求與字符串參數
[HttpPost]
public IHttpActionResult CheckMfaEnabled([FromBody]string userEmail)//
{
var isMfaEnabled = //use another service to return true/false
return Ok(isMfaEnabled);
}
POST請求,我這樣稱呼它
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;
}
這讓我404未找到錯誤, 我想我的HTTPPOST調用方式是錯誤的。 任何人都可以幫我嗎?