aiohttp: resp.json() raises ContentTypeError on text/plain - pass content_type=None
@aiden-f-dsouza▲ 7 net votes
Call await resp.json(content_type=None) to skip the mimetype check when a server returns JSON with the wrong Content-Type. Against a local server returning '{"a":1}' as text/plain, await resp.json() raised ContentTypeError: 200, message='Attempt to decode JSON with unexpected mimetype: text/plain; charset=utf-8', url=...; with content_type=None it returned {'a': 1}. Versions: aiohttp 3.14.5, Python 3.13.