Billing Setup start_time gives error

379 views
Skip to first unread message

market test

unread,
Mar 11, 2021, 10:30:09 AM3/11/21
to AdWords API and Google Ads API Forum
I'm trying to set a Billing setup for an account i just created, and it launches the next error.

Request made: ClientCustomerId: 3062310149, Host: googleads.googleapis.com:443, Method: /google.ads.googleads.v6.services.BillingSetupService/MutateBillingSetup, RequestId: cmg74mcLweuMLRSD3wdQ_g, IsFault: True, FaultMessage: The error code is not in this version.
Request with ID "cmg74mcLweuMLRSD3wdQ_g" failed with status "INVALID_ARGUMENT" and includes the following errors:
        Error with message "The error code is not in this version.".
                On field: operation
                On field: create
                On field: start_time

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?

Google Ads API Forum Advisor Prod

unread,
Mar 12, 2021, 2:40:53 PM3/12/21
to market.te...@gmail.com, adwor...@googlegroups.com
Hello,

Thanks for reaching out. It looks like you are using the add_billing_setup.py code example provided in the Python client library. I do not see in your code a reference to the payment profile ID or payment account ID, which is specified as arguments in the _create_billing_setup method in the add_billing_setup sample. As these arguments are missing, it seems likely that the error may be related to this. 

Regards,
Matt
Google Ad API Team

Google Logo
Matt
Google Ads API Team
 
 

ref:_00D1U1174p._5004Q2Dui5Y:ref

market test

unread,
Mar 14, 2021, 6:39:23 PM3/14/21
to AdWords API and Google Ads API Forum
Hi, 

Yeah, i'm using that example, and here i only pasted the parte related to the date time, which is what marks the error, but my main function is something like this:

billing_setup = _create_billing_setup(
            client, customer_id, payments_account_id, payments_profile_id
        )
        _set_billing_setup_date_times(client, customer_id, billing_setup)
        print(billing_setup)
        billing_setup_operation = client.get_type(
            "BillingSetupOperation", version="v6"
        )
        billing_setup_operation.create.CopyFrom(billing_setup)
        billing_setup_service = client.get_service(
            "BillingSetupService", version="v6"
        )
        response = billing_setup_service.mutate_billing_setup(
            customer_id, billing_setup_operation
        )

The payment profile id is setted on the first line, then that setup is the one sended on the second one to set the date time, desgracefully i can't know which causes the error, since the log only marks: "The error code is not in this version." and the farteri can get is that message that it happened on the field start_time.

Google Ads API Forum Advisor Prod

unread,
Mar 15, 2021, 3:44:34 PM3/15/21
to market.te...@gmail.com, adwor...@googlegroups.com
Hello,

Thanks for providing that extra information. Would you be able to provide us with the complete request and response logs so that we can take a closer look at this issue?

Thanks,

market test

unread,
Mar 15, 2021, 4:24:30 PM3/15/21
to AdWords API and Google Ads API Forum
Hi, 

Yeah, of course, this is the log i got from the logger(I removed the sensible data for security pourposes):

[2021-03-15 14:19:24,165 - INFO] Request made: ClientCustomerId: {customerId}, Host: googleads.googleapis.com:443, Method: /google.ads.googleads.v6.services.GoogleAdsService/SearchStream, RequestId: 3NBLHyipm6uZHaIz_0eZfQ, IsFault: False, FaultMessage: None
[2021-03-15 14:19:25,162 - INFO] Request
-------
Method: /google.ads.googleads.v6.services.BillingSetupService/MutateBillingSetup
Headers: {
  "developer-token": "REDACTED",
  "login-customer-id": " {logincustomerId}  ",
  "x-goog-api-client": "gl-python/3.8.5 grpc/1.33.2 gax/1.23.0 gapic/8.0.0",
  "x-goog-request-params": "customer_id= {customerId}  "
}
Request: customer_id: " {customerId}  "
operation {
  create {
    start_date_time: "2021-03-15 14:19:24"
    end_date_time: "2021-03-16 14:19:24"
    payments_account: "customers/ {customerId}  /paymentsAccounts/ {paymentsaccountId}  "
  }
}


Response
-------
Headers: {
  "google.ads.googleads.v6.errors.googleadsfailure-bin": "\nS\n\u0002\b\u0001\u0012&The error code is not in this version.\"%\u0012\u000b\n\toperation\u0012\b\n\u0006create\u0012\f\n\nstart_time",
  "grpc-status-details-bin": "\b\u0003\u0012%Request contains an invalid argument.\u001a\u0001\nCtype.googleapis.com/google.ads.googleads.v6.errors.GoogleAdsFailure\u0012U\nS\n\u0002\b\u0001\u0012&The error code is not in this version.\"%\u0012\u000b\n\toperation\u0012\b\n\u0006create\u0012\f\n\nstart_time",
  "request-id": "D_AJb07_vl4Au9HnrybjqQ"
}
Fault: errors {
  error_code {
    request_error: UNKNOWN
  }
  message: "The error code is not in this version."
  location {
    field_path_elements {
      field_name: "operation"
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "start_time"
    }
  }
}


[2021-03-15 14:19:25,162 - WARNING] Request made: ClientCustomerId:  {customerId}  , Host: googleads.googleapis.com:443, Method: /google.ads.googleads.v6.services.BillingSetupService/MutateBillingSetup, RequestId: D_AJb07_vl4Au9HnrybjqQ, IsFault: True, FaultMessage: The error code is not in this version.

Google Ads API Forum Advisor Prod

unread,
Mar 16, 2021, 10:24:52 AM3/16/21
to market.te...@gmail.com, adwor...@googlegroups.com
Hello,

Thanks for providing the full logs along with the request ID. Please allow me to share this info internally and we will provide an update shortly. 

Google Ads API Forum Advisor Prod

unread,
Mar 16, 2021, 12:35:34 PM3/16/21
to market.te...@gmail.com, adwor...@googlegroups.com
Greetings!

I took a look at the stack trace on our servers, and I have the root cause. The error is CUSTOMER_BILLING_ERROR_START_TIME_CAN_NOT_BE_FUTURE. I've filed an issue with my teammates who wrote the code to add this error to a future version of the API. When it's added, you'll see it in the release notes (https://developers.google.com/google-ads/api/docs/release-notes).

Best,
Nadine Wang, Google Ads API Team

ref:_00D1U1174p._5004Q2Dui5Y:ref

market test

unread,
Mar 16, 2021, 12:48:53 PM3/16/21
to AdWords API and Google Ads API Forum
Hi,

That's weird, because i'm setting the time with a datetime,now(), so it's not in the future, i've done also some tests setting it one hour later, and so, to check if the problem wasn't that now(), so maybe you saw one of them, i just want to confirm because i've setted the start_time with both datetime.now() and datetime.now() + timedelta(hours=1), and none works, if so, How should i set the start_time correctly in Python?

Google Ads API Forum Advisor Prod

unread,
Mar 16, 2021, 3:12:16 PM3/16/21
to market.te...@gmail.com, adwor...@googlegroups.com
Hello,

That is odd. Have you tried setting the https://developers.google.com/google-ads/api/reference/rpc/v6/BillingSetup#start_time_type to NOW? That would make it where you don't need to calculate it, and our server would do that at the time of the request. It would be similar to this code example https://developers.google.com/google-ads/api/docs/samples/add-account-budget-proposal#python where we are setting the time to NOW for a budget proposal.

Regards,
Nadine, Google Ads API Team

ref:_00D1U1174p._5004Q2Dui5Y:ref

market test

unread,
Mar 16, 2021, 4:48:42 PM3/16/21
to AdWords API and Google Ads API Forum
Perfecto, it worked with this, just an annotation:

When i tried to set the end_time_type, using 

client.get_type(
        "TimeTypeEnum", version="v6"
    ).FOREVER

Does not work, it needs to be setted as a string "FOREVER", but the start_date_time does not work with "NOW", needs to be an int. Not sure if haveing one as an int, and the other as an String is the expected behavior, but may be a little confusing.

Thanks for your help, have a good day.

Google Ads API Forum Advisor Prod

unread,
Mar 16, 2021, 5:50:40 PM3/16/21
to market.te...@gmail.com, adwor...@googlegroups.com
Hi,

Thanks for following up. I'm glad you got it to work. I'll double-check on that behavior; thanks for bringing that up.

Happy coding,
Reply all
Reply to author
Forward
0 new messages