Today, there was a problem in my company's production environment. The following code was called once, but a dozen duplicate accounts appeared on the Google advertising platform.
Customer customer = new()
{
DescriptiveName = req.DescriptiveName,
CurrencyCode = req.CurrencyCode,
TimeZone = req.TimeZone,
Manager = false,
TrackingUrlTemplate = "{lpurl}?device={device}",
FinalUrlSuffix = "keyword={keyword}&matchtype={matchtype}&adgroupid={adgroupid}"
};
CreateCustomerClientRequest createCustomerClientRequest = new()
{
ValidateOnly = req.ValidateOnly,
CustomerId = req.CustomerId,
CustomerClient = customer
};
// Create the account.
CreateCustomerClientResponse response = customerService.CreateCustomerClient(createCustomerClientRequest);
// Display the result.
var message = string.Format($"Created a customer with resource name " +
$"'{response.ResourceName}' under the manager account with customer " +
$"ID '{req.CustomerId}'");