Hey folks, I’m trying to implement an item search in python using the API. I’m using the requests library and I can’t see why I’m not getting any results back. I’m getting a valid response from the endpoint, so I’m authenticating correctly but the returned JSON is
{'page': 1, 'pageSize': 0, 'maxPageSize': 100, 'pageCount': 0, 'results': []}
This is the function:
def search_for_item(name):
access_token = __get_access_token()
search_endpoint = 'https://us.api.blizzard.com/data/wow/search/item'
headers= {'Authorization': f"Bearer {access_token}"}
params = {'namespace': 'static-us','name.en_US': name,':region': 'us'}
response = requests.get(search_endpoint,params=params,headers=headers)
return response.json()
The variable ‘name’ is just a plain string. I thought it might be to do with escaping spaces, but when I try with an item with single word for it’s name I get the same response.
Anyone got any ideas?
Update 19/09/24
I ended up solving this.
Sending the access token in the header always resulted in an authenticated session, but with no results returned in the JSON object.
Sending the access token as a parameter of the get request worked and returned results.
I don’t know if I’m missing something here using the access token in the header, but it’s working for now.