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!