I have a simple stored procedure which get user name and password and SELECT all info and return it.
I have this request code here:
[AcceptVerbs("GET", "POST")]
public Student GetInfoByLogin(Student studentm)
{
//Response response = new Response();
Student student = new Student();
try
{
Connection();
SqlCommand cmd = new SqlCommand("GetInfoByUserNameAndPassword", conn);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserName", studentm.UserName);
cmd.Parameters.AddWithValue("@Password", studentm.Password);
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
student.StundentID = Convert.ToInt32(reader["StudentID"]);
student.UserName = reader["UserName"].ToString();
student.Password = reader["Password"].ToString();
student.PhoneNumber = reader["PhoneNumber"].ToString();
student.Name = reader["Name"].ToString();
student.Age = Convert.ToInt32(reader["Age"]);
student.InstitutionName = reader["InstitutionName"].ToString();
student.RechargedAmount = Convert.ToInt32(reader["RechargedAmount"]);
student.IsPending = Convert.ToInt32(reader["IsPending"]);
}
conn.Close();
}
catch (Exception ex)
{
//
}
return student;
}
I tested this request it works fine in Postman. But when I hit the url there are no info. I am thinking that this is ExecuteReader() operation. It should show show something!!! There are an error log like this:
<Message>The request contains an entity body but no Content-Type header. The inferred media type 'application/octet-stream' is not supported for this resource.</Message>
No MediaTypeFormatter is available to read an object of type 'Student' from content with media type 'application/octet-stream'.
But in Postman it works fine. Can you tell me how to sent POST and use GET to get the returned value in single url call.