Legacy Dev Forum Posts

 View Only

Sign Up

Audit API error - Unable to get 'level' attribute

  • 1.  Audit API error - Unable to get 'level' attribute

    Posted 06-05-2025 18:08

    subhro | 2023-01-19 15:43:14 UTC | #1

    Hello, We have been generating an Audit report but it is throwing an error. Could anyone please help us to fix this.

    We are using Python SDK and trying to get some fields like date, action, user, level etc. We were able to retrieve these fields from API explorer using post Audit query and get Audit query results API.

    { "id": "28560d26-8634-4c9d-a639-xxxx", "pageSize": 50, "cursor": "AW5Y1Dwy/kx/exxxx/H215xxxxx/xxxxxxxxxiP3oaVxxxxGPqq7daxxxxxxx/xxxxlUA==", "entities": [ { "id": "9f239556-e4e0-419d-a4df-xxxxxx", "user": {}, "client": { "id": "" }, "remoteIp": [], "serviceName": "Quality", "level": "SYSTEM", "eventDate": "2023-01-12T06:20:09Z", "action": "Delete", "entity": { "id": "e69a3e69-ee81-493c-98a0-xxxxxx", "selfUri": "/api/v2/conversations/3635fd32-xxxxxx-4ceb-aa9c-xxxxxxx/recordings/e69a3e69-xxxxx-493c-98a0-xxxxx" }, "entityType": "Recording", "status": "SUCCESS", "application": "", "initiatingAction": {}, "transactionInitiator": false, "propertyChanges": [], "context": { "conversationId": "3635fd32-xxxx-4ceb-aa9c-xxxxxxx" }, "entityChanges": [] } }

    But when we execute the same from Python code, we are not able to get "Level" field and its giving below error.

    Request:

    api = PureCloudPlatformClientV2.AuditApi()

    body = PureCloudPlatformClientV2.AuditQueryRequest() audit = PureCloudPlatformClientV2.AuditQueryFilter()

    audit.pcProperty = "EntityType" audit.value = "Recording"

    body.servicename = "Quality" body.filters = [audit] body.interval = "2023-01-12T00:00:00-06:00/2023-01-13T00:00:00-06:00"

    apiresponse1 = api.postauditsquery(body) transactionid = api_response1.id

    apiresponse3 = api.getauditsquerytransactionidresults(transactionid, pagesize = 2000) entities = api_response3.entities

    for item in entities: conv_key = 'conversationId' print (item) Level = item.level

    Response:

    { "errorMessage": "'AuditLogMessage' object has no attribute 'level'", "errorType": "AttributeError", "stackTrace": [ " File \"/var/task/XXfunction.py\", line 103, in generateaudit_report\n Level = item.level\n" ] }

    Function Logs :

    {'action': 'Delete', 'client': {'id': '', 'selfuri': None}, 'context': {'conversationId': 'af7284b3-xxxx-4739-b754-xxxxxx'}, 'entity': {'id': '2c054ede-fefc-4156-b5f0-xxxxxxx', 'selfuri': '/api/v2/conversations/af7284b3-xxxxx-4739-b754-xxxxxx/recordings/2c054ede-xxxx-4156-b5f0-xxxxxx'}, 'entitytype': 'Recording', 'eventdate': datetime.datetime(2023, 1, 12, 0, 5, 31, tzinfo=tzlocal()), 'id': '7c1108b9-xxxxxx-40c3-acca-xxxxxx', 'message': None, 'propertychanges': [], 'remoteip': [], 'servicename': 'Quality', 'user': {'id': None, 'name': None, 'selfuri': None}}


    Zino_Onokpise | 2023-01-23 21:24:03 UTC | #2

    Hi subhro,

    Per the doc: https://developer.genesys.cloud/devapps/sdk/docexplorer/purecloudpython/AuditLogMessage AuditLogMessage does have the attribute 'level'. Please make sure you are using the latest version of the SDK and retest


    system | 2023-02-23 21:24:19 UTC | #3

    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: 18056