meraki / dashboard-api-python

Official Dashboard API library (SDK) for Python
MIT License
293 stars 154 forks source link

Async HTTP calls throws exception with 2XX status code #129

Closed deejaypro closed 3 years ago

deejaypro commented 3 years ago

While playing around with this libary i catched an error with the async functions. In the aio rest-session.py it only accepts a status-code of 200. Every other 2XX status code will throw an exception. For example: The function createNetworkWebhooksWebhookTest will return a 201 (created). This will throw the following exception:

Traceback (most recent call last):
  File "/home/sebastian/PycharmProjects/Meraki_Webhook_Tester.py/src/async_webhook_test.py", line 58, in <module>
    loop.run_until_complete(main())
  File "/usr/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
    return future.result()
  File "/home/sebastian/PycharmProjects/Meraki_Webhook_Tester.py/src/async_webhook_test.py", line 52, in main
    organizationName = await task
  File "/usr/lib/python3.7/asyncio/tasks.py", line 560, in _wait_for_one
    return f.result()  # May raise f.exception().
  File "/home/sebastian/PycharmProjects/Meraki_Webhook_Tester.py/src/async_webhook_test.py", line 29, in test_webhook
    sharedSecret=shared_secret)
  File "/home/sebastian/PycharmProjects/Meraki_Webhook_Tester.py/venv/lib/python3.7/site-packages/meraki/aio/rest_session.py", line 301, in post
    response = await self.request(metadata, "POST", url, json=json)
  File "/home/sebastian/PycharmProjects/Meraki_Webhook_Tester.py/venv/lib/python3.7/site-packages/meraki/aio/rest_session.py", line 94, in request
    return await self._request(metadata, method, url, allow_redirects=False, **kwargs)
  File "/home/sebastian/PycharmProjects/Meraki_Webhook_Tester.py/venv/lib/python3.7/site-packages/meraki/aio/rest_session.py", line 218, in _request
    raise AsyncAPIError(metadata, response, message)
meraki.exceptions.AsyncAPIError: networks, createNetworkWebhooksWebhookTest - 201 Created, {'id': '123456', 'url': 'https://xy', 'status': 'enqueued', 'sharedSecret': 'xxx'}