import sys
import codecs, os

import google.ads.google_ads.client
import logging
logging.basicConfig(level=logging.INFO, format='[%(asctime)s - 
%(levelname)s] %(message).5000s')
logging.getLogger('google.ads.google_ads.client').setLevel(logging.INFO)


def main(client, customer_id, payment_account):


billing_setup_service = client.get_service('BillingSetupService',
version='v4')

billing_setup_operation = client.get_type('BillingSetupOperation',
version='v4')

billing_setup_operation.create = billing_setup_service.billing_setup_path(
customer_id, payment_account)

try:
billing_setup_response = billing_setup_service.mutate_billing_setup(
customer_id, billing_setup_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('Removed billing setup %s.'
% billing_setup_response.results[0].resource_name)

def run():
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
google_ads_client = (google.ads.google_ads.client.GoogleAdsClient
.load_from_storage("C:\\Users\\Kasper 
Aamodt\\PycharmProjects\\google-ads-master\\google-ads.yaml"))

customer_id = '8159363545'
payment_account = '8997522857169420'

main(google_ads_client, customer_id, payment_account)

run()

*That is the code i have, and it returns: *

Traceback (most recent call last):
  File "C:/Users/Kasper 
Aamodt/PycharmProjects/google-ads-master/in_use/connect_billing_account.py", 
line 60, in <module>
    run()
  File "C:/Users/Kasper 
Aamodt/PycharmProjects/google-ads-master/in_use/connect_billing_account.py", 
line 58, in run
    main(google_ads_client, customer_id, payment_account)
  File "C:/Users/Kasper 
Aamodt/PycharmProjects/google-ads-master/in_use/connect_billing_account.py", 
line 25, in main
    billing_setup_operation.create = 
billing_setup_service.billing_setup_path(
  File "C:\Users\Kasper 
Aamodt\Env\venv\lib\site-packages\google\protobuf\internal\python_message.py", 
line 766, in setter
    raise AttributeError('Assignment not allowed to composite field '
AttributeError: Assignment not allowed to composite field "create" in 
protocol message object.

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
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 adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/68174da2-7ae1-4fc5-9418-6d375176ff46n%40googlegroups.com.

Reply via email to