Hello,
Starting 10-Mar-2021 we started getting the exception"The request was aborted: Could not create SSL/TLS secure channel" when calling ExecuteRestPost().
string url = "https://api.hubapi.com/contacts/v1/contact/batch/?hapikey=" + ConfigurationManager.AppSettings["hubSpotApiKey"];
bool resubmit;
do
{
resubmit = false;
HttpResponseMessage response = Utils.ExecuteRestPost(client, url, contacts, false);
if (response.IsSuccessStatusCode)
{
recordsSucceeded += contacts.Count;
}
else // Failure.
{
// For invalid email failures, place any invalid contacts on a list and resubmit the remaining contacts. For any other failures,
// throw an exception and move onto the next batch. Note none of the records in a failed batch are committed to HubSpot, even if they are valid.
JToken invalidEmailsToken = JObject.Parse(response.Content.ReadAsStringAsync().Result)["invalidEmails"];
if (resubmit == false && invalidEmailsToken != null) // Note we never resubmit more than once. If a resubmit fails for any reason, throw an exception.
{
List<string> invalidEmailsList = new List<string>();
foreach (string invalidEmail in invalidEmailsToken)
{
invalidEmailsList.Add(invalidEmail);
Utils.AppendToLog(sbLog, "Invalid email " + invalidEmail);
}
List<Contact1G> validContacts = new List<Contact1G>();
foreach (Contact1G contact in contacts)
{
if (invalidEmailsList.Contains(contact.email))
{
invalidContacts.Add(contact);
}
else
{
validContacts.Add(contact);
}
}
contacts = validContacts;
if (contacts.Count > 0)
{
resubmit = true;
Utils.AppendToLog(sbLog, "Resubmit batch " + batch + " with " + contacts.Count + " valid record(s)");
}
else
{
Utils.AppendToLog(sbLog, "No valid contacts exist in this batch; no resubmit attempted");
}
}
else
{
throw new Exception(Utils.FormatJson(response.Content.ReadAsStringAsync().Result));
}
}
}
while (resubmit == true);
}
catch (Exception ex)
{
Utils.AppendLogErrorHeader(sbLog, ex);
masterException = ex;
}
}
We end up in the catch with the exception stated above. Nothing has changed on our end so I’m hoping you can help us figure out what’s going on here.
Please let me know if there is any other relevant information I can provide.
Thank you