Legacy Dev Forum Posts

 View Only

Sign Up

How to catch the error in the get_analytics_conversation_details method in asynchronous mode?

  • 1.  How to catch the error in the get_analytics_conversation_details method in asynchronous mode?

    Posted 06-05-2025 18:08

    Shunt | 2022-09-29 20:18:57 UTC | #1

    Hi,

    I would like to know how to catch the error in the get analytics conversation details method in asynchronous mode?

    I tried to do it this way:

    for conversation_id in convids: try:

    AnalyticsApi.getanalyticsconversationdetails(conversationid, callback=callback_function)

    except ApiException as e:

    print(conversation_id, "ERROR:", e)

    however when it fires the error always appears this way and I can't get it.

    Exception in thread Thread-5 (_callapi): Traceback (most recent call last): File "C:\Users\paulodo\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009, in bootstrapinner self.run() File "C:\Users\paulodo\AppData\Local\Programs\Python\Python310\lib\threading.py", line 946, in run self.target(*self.args, self.kwargs) File "C:\Users\paulodo\AppData\Local\Programs\Python\Python310\lib\site-packages\PureCloudPlatformClientV2\apiclient.py", line 343, in _callapi responsedata = self.request(method, url, queryparams=queryparams, File "C:\Users\paulodo\AppData\Local\Programs\Python\Python310\lib\site-packages\PureCloudPlatformClientV2\apiclient.py", line 551, in request return self.restclient.GET(url, File "C:\Users\paulodo\AppData\Local\Programs\Python\Python310\lib\site-packages\PureCloudPlatformClientV2\rest.py", line 202, in GET return self.request("GET", url, File "C:\Users\paulodo\AppData\Local\Programs\Python\Python310\lib\site-packages\PureCloudPlatformClientV2\rest.py", line 197, in request raise ApiException(httpresp=r) PureCloudPlatformClientV2.rest.ApiException: (404) Reason: Not Found HTTP response headers: HTTPHeaderDict({'Content-Type': 'application/json', 'Content-Length': '224', 'Connection': 'keep-alive', 'Date': 'Thu, 29 Sep 2022 19:07:09 GMT', 'ININ-Correlation-Id': '34412c52-0ab2-4831-af73-3711af175a8e', 'Strict-Transport-Security': 'max-age=600; includeSubDomains', 'Cache-Control': 'no-cache, no-store, must-revalidate', 'X-Cache': 'Error from cloudfront', 'Via': '1.1 65f7295ff05cf36f1a9f5c741069f294.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'GRU3-C2', 'X-Amz-Cf-Id': 'zCzYs8AZ_xqxkOqDhnB49UVcsazyy1pANbY7obd0E4HmvD7DXXTznQ=='}) HTTP response body: {"message**":"Conversation 025c3def-c283-4489-ac46-5dd177e56414 was invalid or could not be found","code":"not.found","status":404,"messageParams":{},"contextId":"34412c52-0ab2-4831-af73-3711af175a8e","details":[],"errors":[]}

    I would like to present the error more cleanly with just the message.

    Regards,

    Paulo


    anon14299330 | 2022-10-04 17:41:00 UTC | #2

    Hi,

    The threading is a feature of Python's internal libraries and not the SDK and I believe the ApiException error message is just returned as a string in the SDK. You can turn off Python's Traceback by limiting it's depth. For example:

    import sys
    sys.tracebacklimit = 0

    Following this approach, only the ApiException error message will be printed to your terminal. Please let me know if this solution works for you.

    Thanks,

    Mike


    Shunt | 2022-10-03 15:54:49 UTC | #3

    Hi Mike,

    This solution solved my problem.

    Thank you very much.


    system | 2022-11-03 15:55:39 UTC | #4

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 16529