So I have this code that POST a JSON data
to my REST API
using c#
try
{
tempquantityofmenu = entQuantity.Text;
CustList custo = new CustList();
CustomerOrder custo1 = new CustomerOrder()
{
menu_name = tempnameofmenu,
menu_quantity = tempquantityofmenu,
menu_code = tempcodeofmenu
};
custo.CUSTOMER_ORDER.Add(custo1);
await Navigation.PushAsync(new OrdernowCategory());
}
catch(Exception ex)
{
DisplayAlert("error", ex.ToString(), "OK");
}
Then I am getting this System.NullReferenceExeption: Object Reference not set to an instance of an object
public class CustomerOrder
{
public string menu_name { get; set; }
public string menu_quantity { get; set; }
public string menu_code { get; set; }
}
public class CustList
{
public List<CustomerOrder> CUSTOMER_ORDER { get; set; }
}
I think my problem here is that when adding a item to the CUSTOMER_ORDER
inside the try catch
is not working