Hello Scott, Were you able to resolve the issue? Please let me know if you are still facing the issue.
Regards, Sai Teja, AdWords API Team. On Friday, September 21, 2018 at 5:34:17 AM UTC-4, [email protected] wrote: > > I'm attempting to pull keyword planner data from the API using the python > lib examples. > > I continue to get the following error: > > suds.WebFault: Server raised fault: > '[TargetingIdeaError.INVALID_SEARCH_PARAMETERS @ > selector.searchParameters.searchParameters[0]; > trigger:'RelatedToQuerySearchParameter']' > > > > > I'm very confused on this error as I'm following the documentation > exactly. Please help! > > AD_GROUP_ID = None > PAGE_SIZE = 100 > > def main(client, ad_group_id=None): > # Initialize appropriate service. > targeting_idea_service = client.GetService( > 'TargetingIdeaService', version='v201802') > > # Construct selector object and retrieve related keywords. > selector = { > 'ideaType': 'KEYWORD', > 'requestType': 'IDEAS' > } > > selector['requestedAttributeTypes'] = [ > 'KEYWORD_TEXT', 'SEARCH_VOLUME', 'CATEGORY_PRODUCTS_AND_SERVICES'] > > offset = 0 > selector['paging'] = { > 'startIndex': str(offset), > 'numberResults': str(PAGE_SIZE) > } > > selector['searchParameters'] = [{ > 'xsi_type': 'RelatedToQuerySearchParameter', > 'queries': ['baseball'] > }] > > # # Language setting (optional). > # selector['searchParameters'].append({ > # # The ID can be found in the documentation: > # # > https://developers.google.com/adwords/api/docs/appendix/languagecodes > # 'xsi_type': 'LanguageSearchParameter', > # 'languages': [{'id': '1000'}] > # }) > > # # Network search parameter (optional) > # selector['searchParameters'].append({ > # 'xsi_type': 'NetworkSearchParameter', > # 'networkSetting': { > # 'targetGoogleSearch': True, > # 'targetSearchNetwork': False, > # 'targetContentNetwork': False, > # 'targetPartnerSearchNetwork': False > # } > # }) > > # # Use an existing ad group to generate ideas (optional) > # if ad_group_id is not None: > # selector['searchParameters'].append({ > # 'xsi_type': 'SeedAdGroupIdSearchParameter', > # 'adGroupId': ad_group_id > # }) > > more_pages = True > while more_pages: > page = targeting_idea_service.get(selector) > > # Display results. > if 'entries' in page: > for result in page['entries']: > attributes = {} > for attribute in result['data']: > attribute_value = attribute['value'] > if 'value' in attribute_value: > attributes[attribute['key']] = attribute_value['value'] > else: > attributes[attribute['key']] = [] > print ('Keyword with "%s" text and average monthly search volume ' > '"%s" was found with Products and Services categories: %s.' > % (attributes['KEYWORD_TEXT'], > attributes['SEARCH_VOLUME'], > attributes['CATEGORY_PRODUCTS_AND_SERVICES'])) > print > else: > print 'No related keywords were found.' > offset += PAGE_SIZE > selector['paging']['startIndex'] = str(offset) > more_pages = offset < int(page['totalNumEntries']) > > > if __name__ == '__main__': > # Initialize client object. > adwords_client = adwords.AdWordsClient.LoadFromStorage() > > main(adwords_client) > > > AD_GROUP_ID = None > PAGE_SIZE = 100 > > def main(client, ad_group_id=None): > # Initialize appropriate service. > targeting_idea_service = client.GetService( > 'TargetingIdeaService', version='v201802') > > # Construct selector object and retrieve related keywords. > selector = { > 'ideaType': 'KEYWORD', > 'requestType': 'IDEAS' > } > > selector['requestedAttributeTypes'] = [ > 'KEYWORD_TEXT', 'SEARCH_VOLUME', 'CATEGORY_PRODUCTS_AND_SERVICES'] > > offset = 0 > selector['paging'] = { > 'startIndex': str(offset), > 'numberResults': str(PAGE_SIZE) > } > > selector['searchParameters'] = [{ > 'xsi_type': 'RelatedToQuerySearchParameter', > 'queries': ['baseball'] > }] > > # # Language setting (optional). > # selector['searchParameters'].append({ > # # The ID can be found in the documentation: > # # > https://developers.google.com/adwords/api/docs/appendix/languagecodes > # 'xsi_type': 'LanguageSearchParameter', > # 'languages': [{'id': '1000'}] > # }) > > # # Network search parameter (optional) > # selector['searchParameters'].append({ > # 'xsi_type': 'NetworkSearchParameter', > # 'networkSetting': { > # 'targetGoogleSearch': True, > # 'targetSearchNetwork': False, > # 'targetContentNetwork': False, > # 'targetPartnerSearchNetwork': False > # } > # }) > > # # Use an existing ad group to generate ideas (optional) > # if ad_group_id is not None: > # selector['searchParameters'].append({ > # 'xsi_type': 'SeedAdGroupIdSearchParameter', > # 'adGroupId': ad_group_id > # }) > > more_pages = True > while more_pages: > page = targeting_idea_service.get(selector) > > # Display results. > if 'entries' in page: > for result in page['entries']: > attributes = {} > for attribute in result['data']: > attribute_value = attribute['value'] > if 'value' in attribute_value: > attributes[attribute['key']] = attribute_value['value'] > else: > attributes[attribute['key']] = [] > print ('Keyword with "%s" text and average monthly search volume ' > '"%s" was found with Products and Services categories: %s.' > % (attributes['KEYWORD_TEXT'], > attributes['SEARCH_VOLUME'], > attributes['CATEGORY_PRODUCTS_AND_SERVICES'])) > print > else: > print 'No related keywords were found.' > offset += PAGE_SIZE > selector['paging']['startIndex'] = str(offset) > more_pages = offset < int(page['totalNumEntries']) > > > if __name__ == '__main__': > # Initialize client object. > adwords_client = adwords.AdWordsClient.LoadFromStorage() > > main(adwords_client) > > > > > > > > > > > > -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ 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]. 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/04f9d613-adf7-46c8-a4ef-8cdd176b1366%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
