Chilkat Online Tools

C / Anypoint Platform APIs / Get audit logs by filter

Back to Collection Items

#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkJsonObject json;
    HCkHttpResponse resp;

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

    http = CkHttp_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 = CkJsonObject_Create();
    CkJsonObject_UpdateString(json,"startDate","2021-04-20T12:05:21.714Z");
    CkJsonObject_UpdateString(json,"endDate","2021-04-21T12:05:21.714Z");
    CkJsonObject_UpdateNewArray(json,"platforms");
    CkJsonObject_UpdateNewArray(json,"objectTypes");
    CkJsonObject_UpdateNewArray(json,"environmentIds");
    CkJsonObject_UpdateNewArray(json,"actions");
    CkJsonObject_UpdateNewArray(json,"objectIds");
    CkJsonObject_UpdateNewArray(json,"userIds");
    CkJsonObject_UpdateBool(json,"ascending",FALSE);
    CkJsonObject_UpdateString(json,"organizationId","af696110-60f8-4a47-9367-e2464a468949");
    CkJsonObject_UpdateInt(json,"offset",0);
    CkJsonObject_UpdateInt(json,"limit",25);

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

    resp = CkHttp_PostJson3(http,"https://domain.com/audit/v2/organizations/{{organization_id}}/query?include_internal=false","application/json",json);
    if (CkHttp_getLastMethodSuccess(http) == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        CkJsonObject_Dispose(json);
        return;
    }

    printf("%d\n",CkHttpResponse_getStatusCode(resp));
    printf("%s\n",CkHttpResponse_bodyStr(resp));
    CkHttpResponse_Dispose(resp);


    CkHttp_Dispose(http);
    CkJsonObject_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": [
  ]
}