Can't connect to API / python3

89 views
Skip to first unread message

targeting...@gmail.com

unread,
Jan 15, 2019, 3:25:08 PM1/15/19
to AdWords API and Google Ads API Forum
Hi everyone! Sorry for my english

Can't connect to API in my test account

What I use / do:
1. Python3, instal setuptools and googleads;
2. Registered new google account (a1) and manager account to it, add real client accounts to management, get test dev token;
3. Registered another new google account (a2) with TEST manager account, make some test client accounts / campaigns / groups / ads / keywords.
* Find some problem (mb it's important) - I can see new test client accounts in overview but can't see it in menu "Accounts" (remove all filters) 1. http://prntscr.com/m7kyiq 2. http://prntscr.com/m7kyqp;
4. Get OAuth 2.0 client id / secret in test manager account (a2)
5. Get generate refresh token
6. in googleads.yaml add:
* developer_token: from first real manager account (a1), 
* client_customer_id: test client account id from test management account (a2, like 123-456-7890)
* client_id, client_secret, refresh_token
6. do some "basic operations" (from examples for python3):
* get_campaigns.py return notehing
* remove_keyword.py (add adgroup and keyword id's) return next error code:
No handlers could be found for logger "googleads.soap"
Traceback (most recent call last):
 
File "remove_keyword.py", line 40, in <module>
    main
(adwords_client, AD_GROUP_ID, CRITERION_ID)
 
File "remove_keyword.py", line 26, in main
    result
= ad_group_criterion_service.mutate(operations)
 
File "/home/pi/.local/lib/python2.7/site-packages/googleads/common.py", line 1396, in MakeSoapRequest
    e
.detail, errors=error_list, message=e.message)
googleads
.errors.GoogleAdsServerFault: [EntityNotFound.INVALID_ID @ operations[0].operand.adGroupId; trigger:'AdGroupId: ###########']

Anybody know where I have mistakes?
Thank you

googleadsapi...@google.com

unread,
Jan 15, 2019, 5:27:06 PM1/15/19
to AdWords API and Google Ads API Forum
Hello, 

You are on the right track for setting up the API. 

In step #3, the test client accounts may not be visible as these test accounts would be in cancelled status and hidden in the regular view. You could see them by following the steps given below: 
  • Sign in to your Google Ads manager account.
  • Open the navigational panel by pointing your cursor over the left-hand side of the page, or clicking the arrow icon in the upper left corner.
  • Click the 3-dot icon on the navigation panel, then click the check box for cancelled accounts.
In step #6, could you confirm if you specified the client customer id of the test manager account or the test client account? To make API calls to CampaignService, AdGroupCriterionService etc, you will need to specify the client customer id of the test client account in which the campaign and keywords exist and not that of the manager account. If you are specifying the right client customer Id, could you please enable logging and share the SOAP logs of your API call?  You could share the details using reply privately to author option. 


Thanks,
Sreelakshmi, AdWords API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 adwor...@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscribe@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+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/adwords-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/adwords-api/c39ffdc0-14e0-40ce-8af7-029663b2f487%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

targeting...@gmail.com

unread,
Jan 27, 2019, 10:45:45 PM1/27/19
to AdWords API and Google Ads API Forum
Thank you for your reply

In googleads.yaml I add in client customer id 415-313-9860, it's not manager account id

about logging and SOAP...not shure, that I did everything right: just uncomment nextone in googleads.yaml:

logging:
  version
: 1
  disable_existing_loggers
: False
  formatters
:
    default_fmt
:
      format
: ext://googleads.util.LOGGER_FORMAT
  handlers
:
    default_handler
:
     
class: logging.StreamHandler
      formatter
: default_fmt
      level
: INFO
  loggers
:
   
Configure root logger
   
"":
      handlers
: [default_handler]
      level
: INFO

and what I receive when start get_campaigns.py:

pi@raspberrypi:~/Downloads $ python get_campaigns.py
Traceback (most recent call last):

 
File "get_campaigns.py", line 67, in <module>
    adwords_client
= adwords.AdWordsClient.LoadFromStorage()
 
File "/home/pi/.local/lib/python2.7/site-packages/googleads/adwords.py", line 300, in LoadFromStorage
    cls
._OPTIONAL_INIT_VALUES))
 
File "/home/pi/.local/lib/python2.7/site-packages/googleads/common.py", line 289, in LoadFromStorage
    optional_product_values
)
 
File "/home/pi/.local/lib/python2.7/site-packages/googleads/common.py", line 185, in LoadFromString
    data
= yaml.safe_load(yaml_doc) or {}
 
File "/home/pi/.local/lib/python2.7/site-packages/yaml/__init__.py", line 93, in safe_load
   
return load(stream, SafeLoader)
 
File "/home/pi/.local/lib/python2.7/site-packages/yaml/__init__.py", line 71, in load
   
return loader.get_single_data()
 
File "/home/pi/.local/lib/python2.7/site-packages/yaml/constructor.py", line 37, in get_single_data
    node
= self.get_single_node()
 
File "/home/pi/.local/lib/python2.7/site-packages/yaml/composer.py", line 36, in get_single_node
    document
= self.compose_document()
 
File "/home/pi/.local/lib/python2.7/site-packages/yaml/composer.py", line 55, in compose_document
    node
= self.compose_node(None, None)
 
File "/home/pi/.local/lib/python2.7/site-packages/yaml/composer.py", line 84, in compose_node
    node
= self.compose_mapping_node(anchor)
 
File "/home/pi/.local/lib/python2.7/site-packages/yaml/composer.py", line 133, in compose_mapping_node
    item_value
= self.compose_node(node, item_key)
 
File "/home/pi/.local/lib/python2.7/site-packages/yaml/composer.py", line 84, in compose_node
    node
= self.compose_mapping_node(anchor)
 
File "/home/pi/.local/lib/python2.7/site-packages/yaml/composer.py", line 127, in compose_mapping_node
   
while not self.check_event(MappingEndEvent):
 
File "/home/pi/.local/lib/python2.7/site-packages/yaml/parser.py", line 98, in check_event
   
self.current_event = self.state()
 
File "/home/pi/.local/lib/python2.7/site-packages/yaml/parser.py", line 428, in parse_block_mapping_key
   
if self.check_token(KeyToken):
 
File "/home/pi/.local/lib/python2.7/site-packages/yaml/scanner.py", line 116, in check_token
   
self.fetch_more_tokens()
 
File "/home/pi/.local/lib/python2.7/site-packages/yaml/scanner.py", line 223, in fetch_more_tokens
   
return self.fetch_value()
 
File "/home/pi/.local/lib/python2.7/site-packages/yaml/scanner.py", line 579, in fetch_value
   
self.get_mark())
yaml
.scanner.ScannerError: mapping values are not allowed here
 
in "<string>", line 93, column 7:
       
"":
         
^



среда, 16 января 2019 г., 0:27:06 UTC+2 пользователь googleadsapi-forumadvisor написал:

googleadsapi...@google.com

unread,
Jan 28, 2019, 3:40:25 PM1/28/19
to AdWords API and Google Ads API Forum
Hello,

The issue seems to be due to un-commenting the empty quotes ("") followed by colon (:) in the googleads.yaml. To enable logging, you could also add the two lines given here in your program. If you are still facing issues in enabling the SOAP logs, could you share your code? I can confirm that the CID shared is a client customer id of a test client account. 

You could use reply privately to author while sharing the details. 


Thanks,
Sreelakshmi, AdWords API Team

=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog and discussion group:
    http://googleadsdeveloper.blogspot.com/search/label/adwords_api
    https://developers.google.com/adwords/api/community/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

Reply all
Reply to author
Forward
0 new messages