Hi I am testing TargetingIdeaService (google ads api). However, the source code suggested by Google does not work and I am posting a question here.
The source code is written the same as the sample code, but [TargetingIdeaError.INVALID_SEARCH_PARAMETERS] error is occurring. Has anyone solved this problem? Thank you for your help. The attachment is the source file you are creating. Please write down some of the source code and error logs below and I would appreciate your help. >>> Source Code adwords_client = adwords.AdWordsClient.LoadFromStorage('googleads.yaml') targeting_idea_service = adwords_client.GetService('TargetingIdeaService', version='v201809') offset = 0 PAGE_SIZE = 100 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': ['space cruise','hyundai sonata'] }] logging.basicConfig(level=logging.INFO, format=googleads.util.LOGGER_FORMAT) logging.getLogger('googleads.soap').setLevel(logging.DEBUG) print('==================== Debug') page = targeting_idea_service.get(selector) for result in page['entries']: attributes = {} for attribute in result['data']: attributes[attribute['key']] = getattr( attribute['value'], 'value', '0') 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('==================== result') >>> Error Log [2019-01-31 11:10:47,506 - googleads.soap - INFO] Request made: Service: "TargetingIdeaService" Method: "get" URL: "https://adwords.google.com/api/adwords/o/v201809/TargetingIdeaService" [2019-01-31 11:10:47,507 - googleads.soap - DEBUG] Outgoing request: {'SOAPAction': '""', 'Content-Type': 'text/xml; charset=utf-8', 'authorization': 'REDACTED'} <soap-env:Envelope xmlns:soap-env= "http://schemas.xmlsoap.org/soap/envelope/"> <soap-env:Header> <ns0:RequestHeader xmlns:ns0= "https://adwords.google.com/api/adwords/o/v201809"> <ns1:developerToken xmlns:ns1= "https://adwords.google.com/api/adwords/cm/v201809">YgvqxXzMNMs9POV6b1 ICwg</ns1:developerToken> <ns2:userAgent xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201809">unknown (AwApi-Python, googleads/15.0.2, Python/3.7.1, zeep)</ns2:userAgent> <ns3:validateOnly xmlns:ns3= "https://adwords.google.com/api/adwords/cm/v201809">false</ns3:validateOnly> <ns4:partialFailure xmlns:ns4= "https://adwords.google.com/api/adwords/cm/v201809">false</ns4 :partialFailure> </ns0:RequestHeader> </soap-env:Header> <soap-env:Body> <ns0:get xmlns:ns0="https://adwords.google.com/api/adwords/o/v201809"> <ns0:selector> <ns0:searchParameters xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns0:RelatedToQuerySearchParameter"> <ns0:queries>space</ns0:queries> </ns0:searchParameters> <ns0:ideaType>KEYWORD</ns0:ideaType> <ns0:requestType>IDEAS</ns0:requestType> <ns0:requestedAttributeTypes>KEYWORD_TEXT</ns0:requestedAttributeTypes> <ns0:requestedAttributeTypes>SEARCH_VOLUME</ns0:requestedAttributeTypes> <ns0:requestedAttributeTypes>CATEGORY_PRODUCTS_AND_SERVICES</ns0 :requestedAttributeTypes> <ns0:paging> <ns1:startIndex xmlns:ns1= "https://adwords.google.com/api/adwords/cm/v201809">0</ns1:startIndex> <ns2:numberResults xmlns:ns2= "https://adwords.google.com/api/adwords/cm/v201809">100</ns2:numberResults> </ns0:paging> </ns0:selector> </ns0:get> </soap-env:Body> </soap-env:Envelope> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <ResponseHeader xmlns:ns2= "https://adwords.google.com/api/adwords/cm/v201809" xmlns= "https://adwords.google.com/api/adwords/o/v201809"> <ns2:requestId>000580b788f6da410aa30069080f98f1</ns2:requestId> <ns2:serviceName>TargetingIdeaService</ns2:serviceName> <ns2:methodName>get</ns2:methodName> <ns2:operations>1</ns2:operations> <ns2:responseTime>131</ns2:responseTime> </ResponseHeader> </soap:Header> <soap:Body> <soap:Fault> <faultcode>soap:Server</faultcode> <faultstring>[TargetingIdeaError.INVALID_SEARCH_PARAMETERS @ selector.searchParameters.searchParameters[0]; trigger:\'RelatedToQuerySearchParameter\']</faultstring> <detail> <ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/o/v201809" xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201809"> <ns2:message>[TargetingIdeaError.INVALID_SEARCH_PARAMETERS @ selector.searchParameters.searchParameters[0]; trigger:\'RelatedToQuerySearchParameter\']</ns2:message> <ns2:ApplicationException.Type>ApiException</ns2:ApplicationException.Type> <ns2:errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type= "TargetingIdeaError"> <ns2:fieldPath>selector.searchParameters.searchParameters[0]</ns2:fieldPath> <ns2:fieldPathElements> <ns2:field>selector</ns2:field> </ns2:fieldPathElements> <ns2:fieldPathElements> <ns2:field>searchParameters</ns2:field> </ns2:fieldPathElements> <ns2:fieldPathElements> <ns2:field>searchParameters</ns2:field> <ns2:index>0</ns2:index> </ns2:fieldPathElements> <ns2:trigger>RelatedToQuerySearchParameter</ns2:trigger> <ns2:errorString>TargetingIdeaError.INVALID_SEARCH_PARAMETERS</ns2 :errorString> <ns2:ApiError.Type>TargetingIdeaError</ns2:ApiError.Type> <reason>INVALID_SEARCH_PARAMETERS</reason> </ns2:errors> </ApiExceptionFault> </detail> </soap:Fault> </soap:Body> </soap:Envelope> 2019-01-31 11:10:49,097 - googleads.soap - WARNING] Error summary: {'faultMessage': "[TargetingIdeaError.INVALID_SEARCH_PARAMETERS @ selector.searchParameters.searchParameters[0]; trigger:'RelatedToQuerySearchParameter']", 'requestId': '000580b788f6da410aa 30069080f98f1', 'serviceName': 'TargetingIdeaService', 'methodName': 'get', 'operations': '1', 'responseTime': '131'} [TargetingIdeaError.INVALID_SEARCH_PARAMETERS @ selector.searchParameters.searchParameters[0]; trigger:'RelatedToQuerySearchParameter'] [TargetingIdeaError.INVALID_SEARCH_PARAMETERS @ selector.searchParameters.searchParameters[0]; trigger:'RelatedToQuerySearchParameter'] Traceback (most recent call last): File "/Users/tw.kim/Documents/myApp/pythontest/youtubeTest/lib/python3.7/site-packages/googleads/common.py", line 1382, in MakeSoapRequest *packed_args, _soapheaders=soap_headers)['body']['rval'] File "/Users/tw.kim/Documents/myApp/pythontest/youtubeTest/lib/python3.7/site-packages/zeep/proxy.py", line 42, in __call__ self._op_name, args, kwargs) File "/Users/tw.kim/Documents/myApp/pythontest/youtubeTest/lib/python3.7/site-packages/zeep/wsdl/bindings/soap.py", line 132, in send return self.process_reply(client, operation_obj, response) File "/Users/tw.kim/Documents/myApp/pythontest/youtubeTest/lib/python3.7/site-packages/zeep/wsdl/bindings/soap.py", line 194, in process_reply return self.process_error(doc, operation) File "/Users/tw.kim/Documents/myApp/pythontest/youtubeTest/lib/python3.7/site-packages/zeep/wsdl/bindings/soap.py", line 299, in process_error detail=fault_node.find('detail')) zeep.exceptions.Fault: [TargetingIdeaError.INVALID_SEARCH_PARAMETERS @ selector.searchParameters.searchParameters[0]; trigger:'RelatedToQuerySearchParameter'] During handling of the above exception, another exception occurred: Traceback (most recent call last): File "20190130.py", line 28, in <module> page = targeting_idea_service.get(selector) File "/Users/tw.kim/Documents/myApp/pythontest/youtubeTest/lib/python3.7/site-packages/googleads/common.py", line 1396, in MakeSoapRequest e.detail, errors=error_list, message=e.message) googleads.errors.GoogleAdsServerFault: [TargetingIdeaError.INVALID_SEARCH_PARAMETERS @ selector.searchParameters.searchParameters[0]; trigger:'RelatedToQuerySearchParameter'] -- -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ 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. 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/0d69da81-f976-4fa9-b63e-61b102a8e4d7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
from googleads import adwords import googleads.util import logging adwords_client = adwords.AdWordsClient.LoadFromStorage('googleads.yaml') targeting_idea_service = adwords_client.GetService('TargetingIdeaService', version='v201809') offset = 0 PAGE_SIZE = 100 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': ['space cruise','hyundai sonata'] }] logging.basicConfig(level=logging.INFO, format=googleads.util.LOGGER_FORMAT) logging.getLogger('googleads.soap').setLevel(logging.DEBUG) print('==================== Debug') page = targeting_idea_service.get(selector) for result in page['entries']: attributes = {} for attribute in result['data']: attributes[attribute['key']] = getattr( attribute['value'], 'value', '0') 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('==================== result') #Create dictionary with keyword, search volume pair all_results={} for result in page['entries']: try: for attribute in result['data']: if attribute['key']=="KEYWORD_TEXT": word=attribute['value']['value'] if attribute['key']=="SEARCH_VOLUME": volume=attribute['value']['value'] if attribute['key']=="COMPETITION": competition=attribute['value']['value'] all_results[word]=[volume,competition] except AttributeError as e: e=e print(all_results) print('=======')