pseudonym117 / Riot-Watcher

Simple Python wrapper for the Riot Games API for League of Legends
MIT License
531 stars 150 forks source link

Expecting value: line 1 column 1 (char 0) #203

Closed malik-ben closed 2 years ago

malik-ben commented 2 years ago

Hi, In the very beginning, when I try out the example, when I reach this part: versions = lol_watcher.data_dragon.versions_for_region(my_region)

I get the following error:

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Any help ? Thanks

Silver15987 commented 2 years ago

This is the case when the JSON response is not well-formed or empty, Python will throw json.decoder.jsondecodeerror: expecting value: line 1 column 1 (char 0). Response for the version query for the region 'euw1' comes out as {"n":{"item":"12.4.1","rune":"7.23.1","mastery":"7.23.1","summoner":"12.4.1","champion":"12.4.1","profileicon":"12.4.1","map":"12.4.1","language":"12.4.1","sticker":"12.4.1"},"v":"12.4.1","l":"en_GB","cdn":"https://ddragon.leagueoflegends.com/cdn","dd":"12.4.1","lg":"12.4.1","css":"12.4.1","profileiconmax":28,"store":"None"} The reason this might be happening can be due to a bad query, maybe check your API key, regenerate it. Or check what response code you are receiving, a simple try-catch block should be able to fix ut.

pseudonym117 commented 2 years ago

The region for the data dragon call is not the same as the region for any other API calls. specifically, na1/americas is na in ddragon, euw1/europe is eu, etc.

If an incorrect region is specified, the error coming back from riot is nonsense, so there sadly isnt much better behavior here...