Python: get_keyword_ideas.py exception: NoneType is not iterable

85 views
Skip to first unread message

Steve R. Hastings

unread,
Mar 8, 2017, 5:28:27 PM3/8/17
to AdWords API Forum
My company has been using AdWords and I have a copy of the credentials (developer token, etc.) that other people are using.  I'm trying to run the example code from the Python library for getting keyword suggestions.

When I try to run this: examples/adwords/v201609/optimization/get_keyword_ideas.py

I am getting this exception: TypeError: argument of type 'NoneType' is not iterable


It seems clear that the example expects to get a dictionary back from the targeting_idea_service.get() and instead it is getting a Python None object back.

I've tried get_keyword_ideas.py from other versioned subdirectories.  I get a versioning error from the one in v201702, but otherwise I get the same None issue.

How can I successfully get keyword suggestions using Python?

Peter Oliquino

unread,
Mar 8, 2017, 10:48:32 PM3/8/17
to AdWords API Forum
Hi Steve,

Have you made any changes in the get_keyword_ideas.py file or did you run it as is? To help us narrow down the root cause of the issue, could you provide us SOAP request and response for when you encountered the error? Please reply using reply privately to author.

Thanks and regards,
Peter
AdWords API Team

Steve R. Hastings

unread,
Mar 9, 2017, 12:46:03 AM3/9/17
to AdWords API Forum
I found instructions for how to log the SUDS request and response from a blog post: https://blogs.it.ox.ac.uk/inapickle/2011/05/15/using-logging-to-debug-what-suds-is-sending-across-the-wire/

I logged and inspected what the test app was sending.  verify_only was set to True.  It was set in the $HOME/googleads.yaml file, so AdWords was verifying the request and sending back no data.  When I edited the googleads.yaml file, I must have uncommented the verify_only parameter.

With the verify_only parameter set to False, it works as expected and I get keyword suggestions back from AdWords.

Peter Oliquino, thank you for the help.

Peter Oliquino

unread,
Mar 9, 2017, 12:50:40 AM3/9/17
to AdWords API Forum
Hi Steve,

Glad to know you've found the solution. As for enabling your SOAP, you can refer to this section of the Python library setup guide. The same guide in the link should provide a step by step process on how to setup your client library. Should you have any other questions, please feel free to write back.

Best regards,
Peter
AdWords API Team

femi bilesanmi

unread,
May 19, 2017, 9:22:15 AM5/19/17
to AdWords API Forum
Hello , I am also facing the same challenge to get the example code for get_keywords_ideas working . I get the error TypeError: argument of type 'NoneType' is not iterable.  
I tried following the solution outlined below but its still not working. 
Please help.

femi bilesanmi

unread,
May 19, 2017, 11:33:11 AM5/19/17
to AdWords API Forum
I found a solution. Apparently instead of verify_only, we now have validate_only. So uncommented it and set the value to False and it worked for me. Thanks Steve.
Reply all
Reply to author
Forward
0 new messages