pseudonym117/Riot-Watcher

400/401 Client Error

BANALW opened this issue · 11 comments

When I tried to use 'lol_watcher.match.matchlist_by_puuid' and 'lol_watcher.match.by_id' function, it reported that "HTTPError: 400 Client Error: Bad Request for url: ......". But my api works well at Riot developer page. Can't figure out where is the problem.

Similar issue here, getting a Bad Request as well. @BANALW what does your Python look like?

matches = watcher.match.matchlist_by_puuid(region, name['puuid'])

name is currently storing a username on League. Unless, I have formatted wrong for the parameters? Please do let me know if you were able to make headway in resolving this issue somehow.

@BANALW Found out the issue...so if you have a global variable for the region, I suggest not using it. If you do keep it, make sure within matches = watcher.match.matchlist_by_puuid(region, name['puuid']) you explicitly specify region = 'americas'. I had set a global variable region = na1 at the top of my code and as such, when passed as an argument to the parameter 'region' I received a 400/401 Request Error. This can be probably be closed now.

E.g.
matches = watcher.match.matchlist_by_puuid(region ='americas', puuid = name['puuid']) This should return a list of matches.

Thanks for the reply, I have tried the method you mentioned above, but I still get a 400/401 or 403 Error. My code is lol_watcher.match.matchlist_by_puuid('americas', '3cB0mJycwREAcSeVp5Yb35UhdvADtvHPHg2eQ0OEPGYkpfESiuq2GS0VUpCeMztYXWZVvnwp9PFONg'). Then I got a 403 error.

If I add region = ‘americas’, I got a positional argument follows keyword argument error.

Apologies for the late reply, have you tried storing the username of interest in a variable called name?

For instance,

name = watcher.summoner.by_name(region, '[Put username here without braces]')

ranked_stats = watcher.league.by_summoner(region, name['id'])
print(ranked_stats)
print('\n')
ranked_solo_stats = ranked_stats[0]

Should RiotWatcher include mapping for regions na1 -> americas? Or alternatively renaming the region argument here to make it clearer there's a difference?

The issue is that in other function region is represented as "eun1/na1...etc" but in this fucntion
the region is expected to be "EUROPE/AMERICA/ASIA"

Josde commented

Should RiotWatcher include mapping for regions na1 -> americas? Or alternatively renaming the region argument here to make it clearer there's a difference?

I guess an automatic mapping would be the best way to go, since AFAIK this is the only function that use these region names.
By the way, in case someone finds this useful: As far as I'm seeing with my tests, Turkish and Russian API endpoints are grouped into "EUROPE", and Oceania is for some reason grouped into "AMERICAS". Other regions follow logic and geography.

The AMERICAS routing value serves NA, BR, LAN, LAS, and OCE. The ASIA routing value serves KR and JP. The EUROPE routing value serves EUNE, EUW, TR, and RU.

From https://developer.riotgames.com/apis#match-v5

I think an automatic mapping should be implemented. Otherwise, developers will all have to implement their own.

Hey guys! I am currently having a similar issue.

my_matches = watcher.match.matchlist_by_puuid(my_region, me['puuid']) print(my_matches)

'me' is storing my summoner info called by watcher.summoner.by_name

I had no issues getting this to run with v4, but v5 is truly proving to be the headache to work around.

had the same issue, noticed that the API has different variables for the regions in match history for some reason. For 'euw1' it is europe, while for 'na1' it's americas.

For error codes:

400:

If you're getting this message, you've most likely entered an incorrect Summoner or Account ID. The most common cause is using an ID that does not belong to the API key you are currently using. It could also be caused by a poorly formed ID.

401:

This error indicates that the request being made did not contain the necessary authentication credentials (e.g., an API key) and therefore the client was denied access. Most likely cause is an API key has not been provided.

403:

possible causes:

  • An invalid API key was provided with the API request
  • A blacklisted API key was provided with the API request
  • The API request was for an incorrect or unsupported path
    • This is quite common when providing the incorrect region to match endpoints, as riot has decided to change this from na1, euw1, eune1, etc to americas, europe, asia
    • Correct region for call and try again

Its possible that a remapper could be added to correct match endpoints. This hasnt been done historically because if riot decides to add a new region, a new version of riotwatcher will need to be published with an updated mapping. This unfortunately may be the best solution though... will look into feasibility.