Keyword stats [The String type doesn't accept collections as value]

94 views
Skip to first unread message

itsnesky

unread,
Oct 25, 2019, 7:35:29 AM10/25/19
to AdWords API and Google Ads API Forum
My function receives as parameter an array (named: keyword) filled with n keywords. I want to extract the average monthly search volume of each one.

When I make the request like this, everything is ok

selector['searchParameters'= [{
      'xsi_type''RelatedToQuerySearchParameter',
      'queries': ['kw1''kw2''kw3']
  }]

But when I assign to 'queries' my array, the API returns this error: The String type doesn't accept collections as value

selector['searchParameters'= [{
      'xsi_type''RelatedToQuerySearchParameter',
      'queries': [keywords]
  }]

So I converted my array to string 

data = str(keywords).strip('[]')

So data = 'kw1', 'kw2', 'kw3'...

And then:

selector['searchParameters'= [{
      'xsi_type''RelatedToQuerySearchParameter',
      'queries': [data]
  }]

It fixes the problem but the API doesn't send any info because 'data' is considered as a unique string and not like a collection of strings.

Any help?

Thanks!

Google Ads API Forum Advisor Prod

unread,
Oct 25, 2019, 1:07:39 PM10/25/19
to zhai...@hotmail.com, adwor...@googlegroups.com

Hi,

Thanks for reaching out. The cause for the issue could be that when you first add the keyword strings in an array you already put them in the [ ], then you are not supposed to put this keywords array in another array, so you could use 'queries': keywords in the code as opposed to 'queries': [keywords]. 

Please let me know if you have any further questions.

Thanks and Regards,
Xiaoming, Google Ads API Team



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