I'm tring to create a new account budget for a google-ads account followed
google-ads-api's guide
from __future__ import absolute_import
import argparse
import sys
import os
import six
import google.ads.google_ads.client
os.environ['https_proxy'] = 'https_proxy'
GG_DEVELOP_TOKEN = "GG_DEVELOP_TOKEN"
credentials_dict_lb = {"token_uri": "https://oauth2.googleapis.com/token",
"token": None, "scopes": ["https://www.googleapis.com/auth/adwords",
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/userinfo.email", "openid"],
"client_id": "client_id",
"refresh_token": "refresh_token", "client_secret": "client_secret"}
def main(client, customer_id, billing_setup_id):
account_budget_proposal_service = client.get_service(
'AccountBudgetProposalService')
billing_setup_service = client.get_service('BillingSetupService',
version='v2')
account_budget_proposal_operation = client.get_type(
'AccountBudgetProposalOperation')
proposal = account_budget_proposal_operation.create
proposal.proposal_type = client.get_type(
'AccountBudgetProposalTypeEnum').CREATE
proposal.billing_setup.value = billing_setup_service.billing_setup_path(
customer_id, billing_setup_id)
proposal.proposed_name.value = 'Account Budget Proposal (example)'
# Specify the account budget starts immediately
proposal.proposed_start_time_type = client.get_type('TimeTypeEnum',
version='v2').NOW
# Alternatively you can specify a specific start time. Refer to the
# AccountBudgetProposal resource documentation for allowed formats.
#
# proposal.proposed_start_date_time = '2020-01-02 03:04:05'
# Specify that the budget runs forever
proposal.proposed_end_time_type = client.get_type('TimeTypeEnum',
version='v2').FOREVER
# Alternatively you can specify a specific end time. Allowed formats are as
# above.
#
# proposal.proposed_end_date_time = '2021-01-02 03:04:05'
# Optional: set notes for the budget. These are free text and do not effect
# budget delivery.
#
# proposal.proposed_notes = client.wrapper
# .string('Received prepayment of $0.01')
proposal.proposed_spending_limit_micros.value = 0
try:
account_budget_proposal_response = (
account_budget_proposal_service.mutate_account_budget_proposal(
customer_id, account_budget_proposal_operation))
except google.ads.google_ads.errors.GoogleAdsException as ex:
print('Request with ID "%s" failed with status "%s" and includes the '
'following errors:' % (ex.request_id, ex.error.code().name))
for error in ex.failure.errors:
print('\tError with message "%s".' % error.message)
if error.location:
for field_path_element in error.location.field_path_elements:
print('\t\tOn field: %s' % field_path_element.field_name)
sys.exit(1)
print('Created account budget proposal "%s".'
% account_budget_proposal_response.result.resource_name)
if __name__ == '__main__':
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
credentials = google.oauth2.credentials.Credentials(**credentials_dict_lb)
client = google.ads.google_ads.client.GoogleAdsClient(credentials,
GG_DEVELOP_TOKEN, login_customer_id='1871151278')
parser = argparse.ArgumentParser(
description='Creates an account budget proposal.')
# The following argument(s) should be provided to run the example.
parser.add_argument('-c', '--customer_id', type=six.text_type,
required=True, help='The Ads customer ID.')
parser.add_argument('-b', '--billing_setup_id', type=six.text_type,
required=True, help='The billing setup ID.')
args = parser.parse_args()
main(client, args.customer_id, args.billing_setup_id)
but got error like below:
Request made: ClientCustomerId: 1135645950, Host: googleads.googleapis.com:
443, Method: /google.ads.googleads.v2.services.AccountBudgetProposalService/
MutateAccountBudgetProposal, RequestId: 7l0JJ7hBfVkKhAGlQjSSgQ, IsFault:
True, FaultMessage: Cannot create a budget proposal that overlaps with an
pending budget proposal or an approved budget.
Request with ID "7l0JJ7hBfVkKhAGlQjSSgQ" failed with status
"INVALID_ARGUMENT" and includes the following errors:
Error with message "Cannot create a budget proposal that overlaps
with an pending budget proposal or an approved budget.".
On field: operation
My biling setup as :
Billing setup with ID "billing_setup_id ", status "APPROVED",
payments_account "customers/1135645950/paymentsAccounts/payments_account_id"
, payments_account_id "payments_account_id", payments_account_name
"Bluefocus蓝瀚", payments_profile_id "payments_profile_id",
payments_profile_name "BlueFocus International Limited",
secondary_payments_profile_id "".
My account budget as :
Account budget "customers/1135645950/accountBudgets/account_budget_id ",
with status "APPROVED", billing setup
"customers/1135645950/billingSetups/billing_setup_id", amount served 0.00,
total adjustments 0.00, approved spending limit "1.0" (proposed "1.0"),
approved start time "value: "2019-09-12 18:46:53"
" (proposed "value: "2019-09-12 18:46:47"
"), approved end time "" (proposed "").
Why I cann't create a new account budget with exist billing setup above?
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/7559c5e4-87b5-41ad-bc98-20b8ac45048d%40googlegroups.com.