DataFlex / Support API / Show Audit Log
Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJResp
Integer iRespStatusCode
String sAction
String sAction_label
String sActor_id
String sActor_name
String sChange_description
String sCreated_at
String sId
String sIp_address
String sSource_id
String sSource_label
String sSource_type
String sV_Url
String sTemp1
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
Set ComBasicAuth Of hoHttp To True
Set ComLogin Of hoHttp To "login"
Set ComPassword Of hoHttp To "password"
Send ComSetRequestHeader To hoHttp "Accept" "application/json"
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComQuickGetSb Of hoHttp "https://example.zendesk.com/api/v2/audit_logs/:audit_log_id" vSbResponseBody To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
Set ComEmitCompact Of hoJResp To False
Showln "Response Body:"
Get ComEmit Of hoJResp To sTemp1
Showln sTemp1
Get ComLastStatus Of hoHttp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComLastHeader Of hoHttp To sTemp1
Showln sTemp1
Showln "Failed."
Procedure_Return
End
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// {
// "audit_log": {
// "action": "<string>",
// "action_label": "<string>",
// "actor_id": "<integer>",
// "actor_name": "<string>",
// "change_description": "<string>",
// "created_at": "<dateTime>",
// "id": "<integer>",
// "ip_address": "<string>",
// "source_id": "<integer>",
// "source_label": "<string>",
// "source_type": "<string>",
// "url": "<string>"
// }
// }
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
Get ComStringOf Of hoJResp "audit_log.action" To sAction
Get ComStringOf Of hoJResp "audit_log.action_label" To sAction_label
Get ComStringOf Of hoJResp "audit_log.actor_id" To sActor_id
Get ComStringOf Of hoJResp "audit_log.actor_name" To sActor_name
Get ComStringOf Of hoJResp "audit_log.change_description" To sChange_description
Get ComStringOf Of hoJResp "audit_log.created_at" To sCreated_at
Get ComStringOf Of hoJResp "audit_log.id" To sId
Get ComStringOf Of hoJResp "audit_log.ip_address" To sIp_address
Get ComStringOf Of hoJResp "audit_log.source_id" To sSource_id
Get ComStringOf Of hoJResp "audit_log.source_label" To sSource_label
Get ComStringOf Of hoJResp "audit_log.source_type" To sSource_type
Get ComStringOf Of hoJResp "audit_log.url" To sV_Url
End_Procedure
Curl Command
curl -u login:password -X GET
-H "Accept: application/json"
https://example.zendesk.com/api/v2/audit_logs/:audit_log_id
Postman Collection Item JSON
{
"name": "Show Audit Log",
"request": {
"method": "GET",
"header": [
{
"key": "Accept",
"value": "application/json"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/audit_logs/:audit_log_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"audit_logs",
":audit_log_id"
],
"variable": [
{
"key": "audit_log_id",
"value": "<integer>"
}
]
},
"description": "#### Allowed For\n\n* Admins on accounts that have audit-log access\n"
},
"response": [
{
"name": "Success response",
"originalRequest": {
"method": "GET",
"header": [
{
"description": "Added as a part of security scheme: basic",
"key": "Authorization",
"value": "Basic <credentials>"
}
],
"url": {
"raw": "{{baseUrl}}/api/v2/audit_logs/:audit_log_id",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"v2",
"audit_logs",
":audit_log_id"
],
"variable": [
{
"key": "audit_log_id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"audit_log\": {\n \"action\": \"<string>\",\n \"action_label\": \"<string>\",\n \"actor_id\": \"<integer>\",\n \"actor_name\": \"<string>\",\n \"change_description\": \"<string>\",\n \"created_at\": \"<dateTime>\",\n \"id\": \"<integer>\",\n \"ip_address\": \"<string>\",\n \"source_id\": \"<integer>\",\n \"source_label\": \"<string>\",\n \"source_type\": \"<string>\",\n \"url\": \"<string>\"\n }\n}"
}
]
}