Skip to content

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

Description

@deejaypro

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'}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions