I'm trying to set a Billing setup for an account i just created, and it launches the next error.
It only mentions that the error is on the start_time, but doesn't mention which is the error. For the Datetime i'm using the basic sample provided in the docs
def _set_billing_setup_date_times(client, customer_id, billing_setup):
query = """
SELECT
billing_setup.end_date_time
FROM billing_setup
WHERE billing_setup.status = APPROVED
ORDER BY billing_setup.end_date_time DESC
LIMIT 1"""
ga_service = client.get_service("GoogleAdsService", version="v6")
response = ga_service.search_stream(customer_id, query)
# Coercing the response iterator to a list causes the stream to be fully
# consumed so that we can easily access the last row in the request.
batches = list(response)
# Checks if any results were included in the response.
if batches:
# Retrieves the ending_date_time of the last BillingSetup.
last_batch = batches[0]
last_row = last_batch.results[0]
last_ending_date_time = last_row.billing_setup.end_date_time
if not last_ending_date_time:
# A null ending date time indicates that the current billing setup
# is set to run indefinitely. Billing setups cannot overlap, so
# throw an exception in this case.
raise Exception(
"Cannot set starting and ending date times for the new billing "
"setup; the latest existing billing setup is set to run "
"indefinitely."
)
try:
# BillingSetup.end_date_time is a string that can be in the format
# %Y-%m-%d or %Y-%m-%d %H:%M:%S. This checks for the first format.
end_date_time_obj = datetime.strptime(
last_ending_date_time, "%Y-%m-%d"
)
except ValueError:
# If a ValueError is raised then the end_date_time string is in the
# second format that includes hours, minutes and seconds.
end_date_time_obj = datetime.strptime(
last_ending_date_time, "%Y-%m-%d %H:%M:%S"
)
# Sets the new billing setup start date to one day after the end date.
start_date = end_date_time_obj + timedelta(days=1)
else:
# If there are no BillingSetup objecst to retrieve, the only acceptable
# start date time is today.
start_date = datetime.now()
billing_setup.start_date_time = start_date.strftime("%Y-%m-%d %H:%M:%S")
billing_setup.end_date_time = (start_date + timedelta(days=1)).strftime(
"%Y-%m-%d %H:%M:%S"
)
I'm not sure what could be wrong here, Does anyone knows what do i need to change?