cisco-en-programmability / dnacentersdk

Cisco DNA Center Python SDK
https://dnacentersdk.readthedocs.io/en/latest/
MIT License
70 stars 31 forks source link

Invoking multiple Get API(Syslog Destination, Email Event Subscription) with 'name' parameter giving exception of JSONDecodeError #156

Open Abhishek-121 opened 1 month ago

Abhishek-121 commented 1 month ago

Prerequisites

Describe the bug

I was working on the configuring and destination and notification and I came up with the issue that if in the Get API if we pass the filter parameter let say 'name' while invoking the Get Syslog Destination and with this name if no destination is present in the Catalyst Center then it will give response with status code 204 and the Exception message -

JSONDecodeError('Expecting value: line 1 column 1 (char 0)')

JSON_Decode_error

Problem is that the code in the dnacenter sdk attempted to decode an empty response body as JSON. Since the response status is 204 (No Content), this is expected behavior, but the code should handle it appropriately.

And there are multiple GET API calls having the same issue -

  1. Get Syslog Destination
  2. Get Syslog Subscription Details
  3. Get Syslog Event Subscription
  4. Get Rest/Webhook Subscriptions Details
  5. Get Rest/Webhook Event Subscriptions
  6. Get Email Subscriptions Details
  7. Get Email Event Subscriptions

Expected behavior Expectation is when API give response status code as 204 then it should be handled in the code as this indicates the empty response and not need to decode the empty response as JSON and instead of giving Execption code should handle it and return None or empty response like we do in other GET API's (For Example - Get Device List API in devices.)

Environment (please complete the following information):