When I try to call , it throws me this error: System.NullReferenceException Message=Object reference not set to an instance of an object. Is there something wrong with the code? Need Help!
public Command RegisterUser
{
get
{
return new Command(async () =>
{
UserInfo user = new UserInfo();
//try
//{
user.UserId = 99;
user.LoginId = "aaaa";
user.FirstName = "aaa";
user.SecondName = "ddd";
user.ThirdName = "dd";
user.DOB = DateTime.Now.Date;
user.PhoneNo = "332323";
user.Email = "aa.aa.com";
user.Password = "aaaa";
string jsonData = JsonConvert.SerializeObject(user);
string url = "http://192.168.18.22:44368/api/User";
HttpClient client1 = new HttpClient();
client1.MaxResponseContentBufferSize = int.MaxValue;
StringContent content = new StringContent(jsonData, Encoding.UTF8, "application/json");
HttpResponseMessage response1 = await client1.PostAsync(url, content);
string result = "";
if (response1 != null)
result = await response1.Content.ReadAsStringAsync();
//}
//catch (Exception ex)
//{
// string eee = "";
//}
});
}
}