From e2a8b1bb06481a665fc7b830ea8775579928f815 Mon Sep 17 00:00:00 2001 From: joarath Date: Fri, 17 Sep 2021 11:40:57 -0400 Subject: [PATCH] Fixing possible null reference exception Fixing possible null reference exception. The response object would always be null in line modified. Change to reference the error response from the controller object. --- CustomerProfiles/CreateCustomerProfile.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 {