diff --git a/CustomerProfiles/CreateCustomerProfile.cs b/CustomerProfiles/CreateCustomerProfile.cs index 9c69da4..10eeefc 100644 --- a/CustomerProfiles/CreateCustomerProfile.cs +++ b/CustomerProfiles/CreateCustomerProfile.cs @@ -105,11 +105,11 @@ public static ANetApiResponse Run(string ApiLoginID, string ApiTransactionKey, s } else { - if (controller.GetErrorResponse().messages.message.Length > 0) + if (controller.GetErrorResponse()?.messages?.message != null && controller.GetErrorResponse().messages.message.Length > 0) { Console.WriteLine("Customer Profile Creation Failed."); - Console.WriteLine("Error Code: " + response.messages.message[0].code); - Console.WriteLine("Error message: " + response.messages.message[0].text); + Console.WriteLine("Error Code: " + controller.GetErrorResponse().messages.message[0].code); + Console.WriteLine("Error message: " + controller.GetErrorResponse().messages.message[0].text); } else {