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._service_name = "Quality"
body._filters = [audit]
body._interval = "2023-01-12T00:00:00-06:00/2023-01-13T00:00:00-06:00"
api_response1 = api.post_audits_query(body)
transaction_id = api_response1.id
api_response3 = api.get_audits_query_transaction_id_results(transaction_id, page_size = 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/XX_function.py", line 103, in generate_audit_report\n Level = item.level\n"
]
}
Function Logs :
{'action': 'Delete',
'client': {'id': '', 'self_uri': None},
'context': {'conversationId': 'af7284b3-xxxx-4739-b754-xxxxxx'},
'entity': {'id': '2c054ede-fefc-4156-b5f0-xxxxxxx',
'self_uri': '/api/v2/conversations/af7284b3-xxxxx-4739-b754-xxxxxx/recordings/2c054ede-xxxx-4156-b5f0-xxxxxx'},
'entity_type': 'Recording',
'event_date': datetime.datetime(2023, 1, 12, 0, 5, 31, tzinfo=tzlocal()),
'id': '7c1108b9-xxxxxx-40c3-acca-xxxxxx',
'message': None,
'property_changes': [],
'remote_ip': [],
'service_name': 'Quality',
'user': {'id': None, 'name': None, 'self_uri': None}}