I have encountered an issue while sending a post request from Angular to my ASP.NET server. I am trying to access the values of my custom model class (SchoolModel) and I can see that all the values are correct inside Angular. However, when I attempt to retrieve these values in ASP.NET, nothing is returned from inside the object. Can someone please assist me if there is something I am overlooking?
Here is my Angular request code:
const headers = {'Content-Type': 'application/json', };
const body = { schoolData };
this.http.post<any>(this.baseUrl + "Api/CreateSchool", body, { headers }).subscribe(response => {
console.log(response);
}, error => console.error(error));
This is my ASP.NET code:
[HttpPost]
[Route("Api/CreateSchool")]
public bool CreateNewSchool(SchoolModel schoolData)
{
bool schoolCreated = false;
// IT PRINTS SCHOOL NAME ONLY
Console.WriteLine("SCHOOL NAME " + schoolData.Name);
return schoolCreated;
}