KeyError: 'accounts'

39 views
Skip to first unread message

A Choe

unread,
Apr 25, 2022, 2:05:14 AM4/25/22
to Google Ads API and AdWords API Forum
Hi, I want to get my marketing report of google ads.

So I installed google api library in my computer.

And then I input my oauth json file, run generate_report.py.

But I got an error.

How can I solve it?

%run -i generate_report.py
--------------------------------------------------------------------------- 
KeyError Traceback (most recent call last) 
File E:\@@@@\generate_report.py:176, in <module> 

      170    print('The credentials have been revoked or expired, please delete the ' 
      171              '"%s" file and re-run the application to re-authorize.' % 
      172              CREDENTIALS_FILE) 
      175 if __name__ == '__main__': 
--> 176   main(sys.argv) 

File E:\ @@@@  \generate_report.py:134, in main(argv) 
      131 with discovery.build('adsense', 'v2', credentials = credentials) as service: 
      132   try
      133     # Let the user pick account if more than one.
--> 134     account_id = get_account_id(service) 
      136     # Retrieve report. 
      137     if saved_report_id: 

File E:\ @@@@  \generate_report.py:51, in get_account_id(service) 
      49 account_id = None 
      50 response = service.accounts().list().execute() 
---> 51 if len(response['accounts']) == 1: 
      52 account_id = response['accounts'][0]['name'] 
      53 else

KeyError: 'accounts'

Google Ads API Forum Advisor

unread,
Apr 25, 2022, 10:16:26 PM4/25/22
to aness...@gmail.com, adwor...@googlegroups.com
Hi A Choe,

Thank you for reaching out to us.

For our team better check on this and to have a full picture on the error you may have encountered, can you share to us the complete API logs privately (request and response with request-id ) so our team can further check?

You may then send the requested logs via the Reply privately to author option. If this option is not available, you may send the details directly to our googleadsa...@google.com alias instead.

Best regards,
Google Logo
Heidi
Google Ads API Team
 


ref:_00D1U1174p._5004Q2aNBww:ref
Reply all
Reply to author
Forward
0 new messages