Skip to content

Attempt to decode JSON with unexpected mimetype #159

@niacobel

Description

@niacobel

Hello,

I am using the following command to fetch card info through iterations :

for i, card_name in enumerate(cards_pile, start=1):
    print('Fetching card: {} | {} of {}'.format(card_name, i, len(cards_pile)))
    data.append(scrython.cards.Named(exact=card_name))

And I got the following error, on a random basis (some cards are fine, some are not, and it's not always the same card that blocks):


 File "C:\Users\niaco\AppData\Roaming\Python\Python311\site-packages\scrython\cards\named.py", line 57, in __init__
    super(Named, self).__init__(self.url)
  File "C:\Users\niaco\AppData\Roaming\Python\Python311\site-packages\scrython\foundation.py", line 35, in __init__
    loop.run_until_complete(main(loop))
  File "C:\Program Files\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\niaco\AppData\Roaming\Python\Python311\site-packages\scrython\foundation.py", line 32, in main
    self.scryfallJson = await getRequest(client, self._url)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\niaco\AppData\Roaming\Python\Python311\site-packages\scrython\foundation.py", line 28, in getRequest
    return await response.json()
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\niaco\AppData\Roaming\Python\Python311\site-packages\aiohttp\client_reqrep.py", line 1104, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://api.scryfall.com/cards/named?set=&exact=Akoum+Hellkite&format=json&face=&version=&pretty=')

After trying to look into it (not an expert), I found this; https://stackoverflow.com/questions/48840378/python-attempt-to-decode-json-with-unexpected-mimetype which suggests that it might be linked to expected data not being of the json format or something?

Can you help me solve the issue please?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions