Skip to content

Commit ce20540

Browse files
removes content-type check for json (meraki#181)
* fix meraki#147 run black over exceptions.py for better readability * removed content-type check for json
1 parent 45ed8db commit ce20540

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

meraki/aio/rest_session.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ async def _request(self, metadata, method, url, **kwargs):
188188
# For non-empty response to GET, ensure valid JSON
189189
try:
190190
if method == "GET":
191-
await response.json()
191+
await response.json(content_type = None)
192192
return response
193193
except (
194194
json.decoder.JSONDecodeError,
@@ -230,7 +230,7 @@ async def _request(self, metadata, method, url, **kwargs):
230230
# 4XX errors
231231
else:
232232
try:
233-
message = await response.json()
233+
message = await response.json(content_type = None)
234234
except aiohttp.client_exceptions.ContentTypeError:
235235
try:
236236
message = (await response.text())[:100]
@@ -275,7 +275,7 @@ async def get(self, metadata, url, params=None):
275275
metadata["url"] = url
276276
metadata["params"] = params
277277
async with await self.request(metadata, "GET", url, params=params) as response:
278-
return await response.json()
278+
return await response.json(content_type = None)
279279

280280
async def get_pages(
281281
self,
@@ -290,7 +290,7 @@ async def get_pages(
290290

291291
async def _download_page(self, request):
292292
response = await request
293-
result = await response.json()
293+
result = await response.json(content_type = None)
294294
return response, result
295295

296296
async def _get_pages_iterator(
@@ -390,7 +390,7 @@ async def _get_pages_legacy(
390390
metadata["page"] = 1
391391

392392
async with await self.request(metadata, "GET", url, params=params) as response:
393-
results = await response.json()
393+
results = await response.json(content_type = None)
394394

395395
# For event log endpoint when using 'next' direction, so results/events are sorted chronologically
396396
if (
@@ -442,10 +442,10 @@ async def _get_pages_legacy(
442442
links = response.links
443443
# Append that page's results, depending on the endpoint
444444
if type(results) == list:
445-
results.extend(await response.json())
445+
results.extend(await response.json(content_type = None))
446446
# For event log endpoint
447447
elif type(results) == dict:
448-
json_response = await response.json()
448+
json_response = await response.json(content_type = None)
449449
start = json_response["pageStartAt"]
450450
end = json_response["pageEndAt"]
451451
events = json_response["events"]
@@ -466,14 +466,14 @@ async def post(self, metadata, url, json=None):
466466
metadata["url"] = url
467467
metadata["json"] = json
468468
async with await self.request(metadata, "POST", url, json=json) as response:
469-
return await response.json()
469+
return await response.json(content_type = None)
470470

471471
async def put(self, metadata, url, json=None):
472472
metadata["method"] = "PUT"
473473
metadata["url"] = url
474474
metadata["json"] = json
475475
async with await self.request(metadata, "PUT", url, json=json) as response:
476-
return await response.json()
476+
return await response.json(content_type = None)
477477

478478
async def delete(self, metadata, url):
479479
metadata["method"] = "DELETE"

0 commit comments

Comments
 (0)