Chilkat Online Tools

VBScript / Anypoint Platform APIs / Get audit logs by filter

Back to Collection Items

Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile("output.txt", True)

' This example assumes the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

set http = CreateObject("Chilkat_9_5_0.Http")

' Use this online tool to generate code from sample JSON: Generate Code to Create JSON

' The following JSON is sent in the request body.

' {
'   "startDate": "2021-04-20T12:05:21.714Z",
'   "endDate": "2021-04-21T12:05:21.714Z",
'   "platforms": [
'   ],
'   "objectTypes": [
'   ],
'   "environmentIds": [
'   ],
'   "actions": [
'   ],
'   "objectIds": [
'   ],
'   "userIds": [
'   ],
'   "ascending": false,
'   "organizationId": "af696110-60f8-4a47-9367-e2464a468949",
'   "offset": 0,
'   "limit": 25
' }

set json = CreateObject("Chilkat_9_5_0.JsonObject")
success = json.UpdateString("startDate","2021-04-20T12:05:21.714Z")
success = json.UpdateString("endDate","2021-04-21T12:05:21.714Z")
success = json.UpdateNewArray("platforms")
success = json.UpdateNewArray("objectTypes")
success = json.UpdateNewArray("environmentIds")
success = json.UpdateNewArray("actions")
success = json.UpdateNewArray("objectIds")
success = json.UpdateNewArray("userIds")
success = json.UpdateBool("ascending",0)
success = json.UpdateString("organizationId","af696110-60f8-4a47-9367-e2464a468949")
success = json.UpdateInt("offset",0)
success = json.UpdateInt("limit",25)

' Adds the "Authorization: Bearer {{token}}" header.
http.AuthToken = "{{token}}"

' resp is a Chilkat_9_5_0.HttpResponse
Set resp = http.PostJson3("https://domain.com/audit/v2/organizations/{{organization_id}}/query?include_internal=false","application/json",json)
If (http.LastMethodSuccess = 0) Then
    outFile.WriteLine(http.LastErrorText)
    WScript.Quit
End If

outFile.WriteLine(resp.StatusCode)
outFile.WriteLine(resp.BodyStr)


outFile.Close

Curl Command

curl -X POST
	-H "Authorization: Bearer {{token}}"
	-d '{
   "startDate":"2021-04-20T12:05:21.714Z",
   "endDate":"2021-04-21T12:05:21.714Z",
   "platforms":[
      
   ],
   "objectTypes":[
      
   ],
   "environmentIds":[
      
   ],
   "actions":[
      
   ],
   "objectIds":[
      
   ],
   "userIds":[
      
   ],
   "ascending":false,
   "organizationId":"af696110-60f8-4a47-9367-e2464a468949",
   "offset":0,
   "limit":25
}'
https://domain.com/audit/v2/organizations/{{organization_id}}/query?include_internal=false

Postman Collection Item JSON

{
  "name": "Get audit logs by filter",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Authorization",
        "value": "Bearer {{token}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\r\n   \"startDate\":\"2021-04-20T12:05:21.714Z\",\r\n   \"endDate\":\"2021-04-21T12:05:21.714Z\",\r\n   \"platforms\":[\r\n      \r\n   ],\r\n   \"objectTypes\":[\r\n      \r\n   ],\r\n   \"environmentIds\":[\r\n      \r\n   ],\r\n   \"actions\":[\r\n      \r\n   ],\r\n   \"objectIds\":[\r\n      \r\n   ],\r\n   \"userIds\":[\r\n      \r\n   ],\r\n   \"ascending\":false,\r\n   \"organizationId\":\"af696110-60f8-4a47-9367-e2464a468949\",\r\n   \"offset\":0,\r\n   \"limit\":25\r\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{url}}/audit/v2/organizations/{{organization_id}}/query?include_internal=false",
      "host": [
        "{{url}}"
      ],
      "path": [
        "audit",
        "v2",
        "organizations",
        "{{organization_id}}",
        "query"
      ],
      "query": [
        {
          "key": "include_internal",
          "value": "false"
        }
      ]
    }
  },
  "response": [
  ]
}