leonhard-s / auraxium

A high-level Python wrapper for the PlanetSide 2 API.
https://auraxium.readthedocs.io/
MIT License
28 stars 8 forks source link

player.events_grouped() error. #36

Closed dbrennand closed 3 years ago

dbrennand commented 3 years ago

Hi,

I just ran into an issue using the library.

The following code produces the error:

payload = await run_query(query, session=self._client.session)
line 106, in run_query
data: CensusData = await response.json()

aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: ', url=URL('https://census.daybreakgames.com/s:example/get/ps2:v2/characters_online_status?character_id=id

My code:

import auraxium
import asyncio

async def main():
    async with auraxium.Client() as client:
        player = await client.get_by_name(auraxium.ps2.Character, "character")
        print(await player.events_grouped())

loop = asyncio.get_event_loop()
loop.run_until_complete(main())
dbrennand commented 3 years ago

Hmm odd. I re-run the code a few minutes later and now the issue is no longer occurring. ๐Ÿค”

Is this occurring because I am hitting the API rate limit perhaps?

leonhard-s commented 3 years ago

Hi, glad to see you were able to resolve the issue/the issue resolved itself.

This kind of error occurs for some API error messages due to the server reporting the response type as plain text while returning JSON data, which upsets the ClientResponse.json() method as per your snippet.

The current master branch should be able to handle this error state - I assume you are on an older version as run_query is defined on line 106 (it has moved since then๐Ÿ˜…)?

Sorry about the versioning, it's been a bit of a mess lately and I have not gotten around to fix it. ๐Ÿ˜ฌ

dbrennand commented 3 years ago

Hi, glad to see you were able to resolve the issue/the issue resolved itself.

This kind of error occurs for some API error messages due to the server reporting the response type as plain text while returning JSON data, which upsets the ClientResponse.json() method as per your snippet.

The current master branch should be able to handle this error state - I assume you are on an older version as run_query is defined on line 106 (it has moved since then๐Ÿ˜…)?

Sorry about the versioning, it's been a bit of a mess lately and I have not gotten around to fix it. ๐Ÿ˜ฌ

Hi @leonhard-s

I am using whatever is the latest version available via pip ๐Ÿ‘

auraxium 0.1.0a1

leonhard-s commented 3 years ago

Hm... I'll have to take a look at that, then.

Thanks again for the report, as I said this should already be resolved - I'll tidy up any loose ends and push a new version as soon as I can find the time.