Recently, I've encountered an issue with my Post API. When calling it through AJAX, the user parameter is received but the StreamReader returns empty.
[HttpPost]
[Route("getUserBankList")]
public IHttpActionResult getUserBankList(UserProfile user)
{
StreamReader reader = new StreamReader(HttpContext.Current.Request.InputStream);
string getUserBankList = reader.ReadToEnd();
}
Additionally, I have another Post API where data is sent via HTML form post. Surprisingly, the req parameter comes back as empty, but the StreamReader successfully retrieves the posted data.
[HttpPost]
[Route("getUserBankList")]
public IHttpActionResult ValidateToken(ValidateRequest req)
{
StreamReader reader = new StreamReader(HttpContext.Current.Request.InputStream);
string getUserBankList = reader.ReadToEnd();
}
I'm puzzled by how differently the two POST requests are handled in terms of sending data. Any insights on this would be greatly appreciated!