I'm running a Python script which uses a value list as query parameters for an HTTP request over an API endpoint. Here a snap:
df = pd.read_excel('grp.xlsx', sheet_name='Sheet1', usecols="A")
for item in df.PLACE:
df.PLACE.head()
#1st level request
def wbsearchentities_q(**kwargs):
params = {
'action': 'wbsearchentities',
'format': 'json',
'language': 'en',
'search': item
}
params.update(kwargs)
response = requests.get(API_ENDPOINT, params=params)
return response
r = wbsearchentities_q(ids=item)
item_id = (r.json()['search'][0]['id'])
item_label = (r.json()['search'][0]['label'])
I'm having this error: IndexError: list index out of range
which means that some items from my list are not recognized by the API endpoint.
I would just pass over and continue the loop. I tried to fix using this without result.
Thanks in advance.