Bug in AIO SDK for generateDeviceCameraSnapshot?

Kind of a big deal
Kind of a big deal

Bug in AIO SDK for generateDeviceCameraSnapshot?

This sample code works (environment has API key):

import meraki

def main():
    response = dashboard.camera.generateDeviceCameraSnapshot("xxxx-xxxx-xxxx")

if __name__ == "__main__":

This AIO version does not:

import meraki.aio,asyncio

async def main():
	async with meraki.aio.AsyncDashboardAPI(print_console=False) as aiomeraki:
		response = await aiomeraki.camera.generateDeviceCameraSnapshot("xxxx-xxxx-xxxx")

if __name__ == "__main__":
	# Execute only if run as a script

It produces the error:

aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/json;charset=utf-8', url=URL('https://api.meraki.com/api/v1/devices/xxxx-xxxx-xxxx/camera/generateSnapshot')




Kind of a big deal
Kind of a big deal

python -V
Python 3.8.10

pip show meraki
Name: meraki
Version: 1.12.0
Summary: Cisco Meraki Dashboard API library
Home-page: https://github.com/meraki/dashboard-api-python
Author: Cisco Meraki
Author-email: api-feedback@meraki.net
License: MIT
Location: /home/ubuntu/.local/lib/python3.8/site-packages
Requires: requests, aiohttp
Kind of a big deal
Kind of a big deal

Just thinking about this further, it mentions the type "text/json".  That's wrong.  It should be "application/json".


If I change "lib/python3.8/site-packages/meraki/aio/rest_session.py", line 410, from:

return await response.json()


return await response.json(content_type=None)

it works.


I think the problem is the API itself is returning the wrong content type, and that the standard Merkai library doesn't check the content type so this error is not showing up.

Head in the Cloud

I've just checked this and the issue is the type checking in aiohttp. There isn't any type checking in the request based library. That's why it is working here.


response.json() is checking, if the content-type is "application/json". For an odd reason in this endpoint the dashboard will return "text/json"


as a workaround I would disable type-checking:



meraki.aio.rest_session.py:Line 470



            return await response.json()






            return await response.json(content_type=None)





In my opinion this is a bug in the endpoint on dashboard itself. Why is this the only (as far as we know yet) endpoint with content-type "text/json" instead of "application/json".
I could make a fix on the client and override the check in aiohttp for "text/json", but that would be a workaround which shouldn't be needed.
Edit: as posted below "text/json" isn't a correct mime type, so it should really be fixed on the endpoint


@PhilipDAth  I'm glad that you came to the same conclusion as I =D

You've just posted yours while I was writing on my reply ^^

According to IANA the correct mime type is "application/json" and "text/json" is completely wrong.
I've opened a support case for this: 07059259

@John-K , could we drag you into this one?  It's a minor bug in an API response.

Thanks @Greenberet, I agree that is a bug and hopefully a trivial fix. I expect the support team will take it from here for escalation to eng.

Head in the Cloud

Supportupdate (~45 minutes ago)

Our development team are still working on getting this resolved. Thank you for your patience so far.
Head in the Cloud

@John-Kcan you push this internally a little bit more? The case is still open and the last update was from today:


I'm afraid there haven't been any further updates from our engineering team on this one. I appreciate this has been open some time, hopefully they will resolve this soon.
Get notified when there are additional replies to this discussion.
Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.