Chilkat Online Tools

unicodeC / Anypoint Platform APIs / Get audit logs by filter

Back to Collection Items

#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    BOOL success;
    HCkJsonObjectW json;
    HCkHttpResponseW resp;

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

    http = CkHttpW_Create();

    // 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
    // }

    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(json,L"startDate",L"2021-04-20T12:05:21.714Z");
    CkJsonObjectW_UpdateString(json,L"endDate",L"2021-04-21T12:05:21.714Z");
    CkJsonObjectW_UpdateNewArray(json,L"platforms");
    CkJsonObjectW_UpdateNewArray(json,L"objectTypes");
    CkJsonObjectW_UpdateNewArray(json,L"environmentIds");
    CkJsonObjectW_UpdateNewArray(json,L"actions");
    CkJsonObjectW_UpdateNewArray(json,L"objectIds");
    CkJsonObjectW_UpdateNewArray(json,L"userIds");
    CkJsonObjectW_UpdateBool(json,L"ascending",FALSE);
    CkJsonObjectW_UpdateString(json,L"organizationId",L"af696110-60f8-4a47-9367-e2464a468949");
    CkJsonObjectW_UpdateInt(json,L"offset",0);
    CkJsonObjectW_UpdateInt(json,L"limit",25);

    // Adds the "Authorization: Bearer {{token}}" header.
    CkHttpW_putAuthToken(http,L"{{token}}");

    resp = CkHttpW_PostJson3(http,L"https://domain.com/audit/v2/organizations/{{organization_id}}/query?include_internal=false",L"application/json",json);
    if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(json);
        return;
    }

    wprintf(L"%d\n",CkHttpResponseW_getStatusCode(resp));
    wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
    CkHttpResponseW_Dispose(resp);


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(json);

    }

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": [
  ]
}