Chilkat Online Tools

PowerBuilder / Atlassian Confluence Cloud / Get audit records for time period

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_V_Type
string ls_DisplayName
string ls_Operations
string ls_Username
string ls_UserKey
string ls_RemoteAddress
integer li_CreationDate
string ls_Summary
string ls_Description
string ls_Category
integer li_SysAdmin
string ls_Name
string ls_ObjectType
integer j
integer li_Count_j
string ls_Name
string ls_OldValue
string ls_NewValue
string ls_ObjectType
integer li_Start
integer li_Limit
integer li_Size
integer i
integer li_Count_i

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

loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_QueryParams = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat.JsonObject")

loo_QueryParams.UpdateInt("number",3)
loo_QueryParams.UpdateString("units","MONTHS")
loo_QueryParams.UpdateString("searchString","<string>")
loo_QueryParams.UpdateInt("start",0)
loo_QueryParams.UpdateInt("limit",1000)

loo_Resp = loo_Http.QuickRequestParams("GET","https://your-domain.atlassian.net/wiki/rest/api/audit/since",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_QueryParams
    return
end if

loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JResp = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)
loo_JResp.EmitCompact = 0

Write-Debug "Response Body:"
Write-Debug loo_JResp.Emit()

li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
    Write-Debug "Response Header:"
    Write-Debug loo_Resp.Header
    Write-Debug "Failed."
    destroy loo_Resp
    destroy loo_Http
    destroy loo_QueryParams
    destroy loo_SbResponseBody
    destroy loo_JResp
    return
end if

destroy loo_Resp

// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)

// {
//   "results": [
//     {
//       "author": {
//         "type": "user",
//         "displayName": "eu qui amet",
//         "operations": null,
//         "username": "ut",
//         "userKey": "amet ut eu Ut"
//       },
//       "remoteAddress": "irure sed commodo tempor",
//       "creationDate": -28489517,
//       "summary": "reprehenderit occaecat",
//       "description": "sed in occaecat",
//       "category": "magna qui Lorem",
//       "sysAdmin": false,
//       "affectedObject": {
//         "name": "Ut est ad eu anim",
//         "objectType": "tempor Excepteur"
//       },
//       "changedValues": [
//         {
//           "name": "non anim sint qui",
//           "oldValue": "amet est qui esse",
//           "newValue": "tempor quis"
//         },
//         {
//           "name": "sed ipsum aut",
//           "oldValue": "culpa",
//           "newValue": "occaecat ad"
//         }
//       ],
//       "associatedObjects": [
//         {
//           "name": "Excepteur fugiat",
//           "objectType": "aute sint quis eiusmod qui"
//         },
//         {
//           "name": "esse laborum in",
//           "objectType": "magna irure"
//         }
//       ]
//     },
//     {
//       "author": {
//         "type": "user",
//         "displayName": "anim nisi occaecat ipsum",
//         "operations": null,
//         "username": "anim in proident ex et",
//         "userKey": "dolore sunt"
//       },
//       "remoteAddress": "ipsum mollit est",
//       "creationDate": -68787259,
//       "summary": "labore cupidatat amet laborum",
//       "description": "et ea dolore",
//       "category": "consequat ex enim occaecat",
//       "sysAdmin": true,
//       "affectedObject": {
//         "name": "irure occaecat proident dolor id",
//         "objectType": "veniam Ut in magna"
//       },
//       "changedValues": [
//         {
//           "name": "proident sunt laboris",
//           "oldValue": "ut sunt dolore ullamco",
//           "newValue": "enim adipisicing"
//         },
//         {
//           "name": "non cillum laborum reprehenderit",
//           "oldValue": "in mollit consectetur",
//           "newValue": "fugiat ut anim pariatur"
//         }
//       ],
//       "associatedObjects": [
//         {
//           "name": "qui anim dolore",
//           "objectType": ""
//         },
//         {
//           "name": "enim pariatur in ut sed",
//           "objectType": "nostrud"
//         }
//       ]
//     }
//   ],
//   "start": -42437008,
//   "limit": 95954729,
//   "size": -54456786,
//   "_links": {}
// }

// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

li_Start = loo_JResp.IntOf("start")
li_Limit = loo_JResp.IntOf("limit")
li_Size = loo_JResp.IntOf("size")
i = 0
li_Count_i = loo_JResp.SizeOfArray("results")
do while i < li_Count_i
    loo_JResp.I = i
    ls_V_Type = loo_JResp.StringOf("results[i].author.type")
    ls_DisplayName = loo_JResp.StringOf("results[i].author.displayName")
    ls_Operations = loo_JResp.StringOf("results[i].author.operations")
    ls_Username = loo_JResp.StringOf("results[i].author.username")
    ls_UserKey = loo_JResp.StringOf("results[i].author.userKey")
    ls_RemoteAddress = loo_JResp.StringOf("results[i].remoteAddress")
    li_CreationDate = loo_JResp.IntOf("results[i].creationDate")
    ls_Summary = loo_JResp.StringOf("results[i].summary")
    ls_Description = loo_JResp.StringOf("results[i].description")
    ls_Category = loo_JResp.StringOf("results[i].category")
    li_SysAdmin = loo_JResp.BoolOf("results[i].sysAdmin")
    ls_Name = loo_JResp.StringOf("results[i].affectedObject.name")
    ls_ObjectType = loo_JResp.StringOf("results[i].affectedObject.objectType")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("results[i].changedValues")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_Name = loo_JResp.StringOf("results[i].changedValues[j].name")
        ls_OldValue = loo_JResp.StringOf("results[i].changedValues[j].oldValue")
        ls_NewValue = loo_JResp.StringOf("results[i].changedValues[j].newValue")
        j = j + 1
    loop
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("results[i].associatedObjects")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_Name = loo_JResp.StringOf("results[i].associatedObjects[j].name")
        ls_ObjectType = loo_JResp.StringOf("results[i].associatedObjects[j].objectType")
        j = j + 1
    loop
    i = i + 1
loop


destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -G -d "number=3"
	-d "units=MONTHS"
	-d "searchString=%3Cstring%3E"
	-d "start=0"
	-d "limit=1000"
https://your-domain.atlassian.net/wiki/rest/api/audit/since

Postman Collection Item JSON

{
  "name": "Get audit records for time period",
  "request": {
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/audit/since?number=3&units=MONTHS&searchString=<string>&start=0&limit=1000",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "audit",
        "since"
      ],
      "query": [
        {
          "key": "number",
          "value": "3",
          "description": "The number of units for the time period."
        },
        {
          "key": "units",
          "value": "MONTHS",
          "description": "The unit of time that the time period is measured in."
        },
        {
          "key": "searchString",
          "value": "<string>",
          "description": "Filters the results to records that have string property values\nmatching the `searchString`."
        },
        {
          "key": "start",
          "value": "0",
          "description": "The starting index of the returned records."
        },
        {
          "key": "limit",
          "value": "1000",
          "description": "The maximum number of records to return per page.\nNote, this may be restricted by fixed system limits."
        }
      ]
    },
    "description": "Returns records from the audit log, for a time period back from the current\ndate. For example, you can use this method to get the last 3 months of records.\n\nThis contains information about events like space exports, group membership\nchanges, app installations, etc. For more information, see\n[Audit log](https://confluence.atlassian.com/confcloud/audit-log-802164269.html)\nin the Confluence administrator's guide.\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\n'Confluence Administrator' global permission."
  },
  "response": [
    {
      "name": "Returned if the requested records are returned.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/audit/since?number=3&units=MONTHS&searchString=<string>&start=0&limit=1000",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "audit",
            "since"
          ],
          "query": [
            {
              "key": "number",
              "value": "3"
            },
            {
              "key": "units",
              "value": "MONTHS"
            },
            {
              "key": "searchString",
              "value": "<string>"
            },
            {
              "key": "start",
              "value": "0"
            },
            {
              "key": "limit",
              "value": "1000"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"results\": [\n  {\n   \"author\": {\n    \"type\": \"user\",\n    \"displayName\": \"eu qui amet\",\n    \"operations\": null,\n    \"username\": \"ut\",\n    \"userKey\": \"amet ut eu Ut\"\n   },\n   \"remoteAddress\": \"irure sed commodo tempor\",\n   \"creationDate\": -28489517,\n   \"summary\": \"reprehenderit occaecat\",\n   \"description\": \"sed in occaecat\",\n   \"category\": \"magna qui Lorem\",\n   \"sysAdmin\": false,\n   \"affectedObject\": {\n    \"name\": \"Ut est ad eu anim\",\n    \"objectType\": \"tempor Excepteur\"\n   },\n   \"changedValues\": [\n    {\n     \"name\": \"non anim sint qui\",\n     \"oldValue\": \"amet est qui esse\",\n     \"newValue\": \"tempor quis\"\n    },\n    {\n     \"name\": \"sed ipsum aut\",\n     \"oldValue\": \"culpa\",\n     \"newValue\": \"occaecat ad\"\n    }\n   ],\n   \"associatedObjects\": [\n    {\n     \"name\": \"Excepteur fugiat\",\n     \"objectType\": \"aute sint quis eiusmod qui\"\n    },\n    {\n     \"name\": \"esse laborum in\",\n     \"objectType\": \"magna irure\"\n    }\n   ]\n  },\n  {\n   \"author\": {\n    \"type\": \"user\",\n    \"displayName\": \"anim nisi occaecat ipsum\",\n    \"operations\": null,\n    \"username\": \"anim in proident ex et\",\n    \"userKey\": \"dolore sunt\"\n   },\n   \"remoteAddress\": \"ipsum mollit est\",\n   \"creationDate\": -68787259,\n   \"summary\": \"labore cupidatat amet laborum\",\n   \"description\": \"et ea dolore\",\n   \"category\": \"consequat ex enim occaecat\",\n   \"sysAdmin\": true,\n   \"affectedObject\": {\n    \"name\": \"irure occaecat proident dolor id\",\n    \"objectType\": \"veniam Ut in magna\"\n   },\n   \"changedValues\": [\n    {\n     \"name\": \"proident sunt laboris\",\n     \"oldValue\": \"ut sunt dolore ullamco\",\n     \"newValue\": \"enim adipisicing\"\n    },\n    {\n     \"name\": \"non cillum laborum reprehenderit\",\n     \"oldValue\": \"in mollit consectetur\",\n     \"newValue\": \"fugiat ut anim pariatur\"\n    }\n   ],\n   \"associatedObjects\": [\n    {\n     \"name\": \"qui anim dolore\",\n     \"objectType\": \"\"\n    },\n    {\n     \"name\": \"enim pariatur in ut sed\",\n     \"objectType\": \"nostrud\"\n    }\n   ]\n  }\n ],\n \"start\": -42437008,\n \"limit\": 95954729,\n \"size\": -54456786,\n \"_links\": {}\n}"
    },
    {
      "name": "Returned if the calling user does not have permission to view the audit\nlog.",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "url": {
          "raw": "{{baseUrl}}/api/audit/since?number=3&units=MONTHS&searchString=<string>&start=0&limit=1000",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "audit",
            "since"
          ],
          "query": [
            {
              "key": "number",
              "value": "3"
            },
            {
              "key": "units",
              "value": "MONTHS"
            },
            {
              "key": "searchString",
              "value": "<string>"
            },
            {
              "key": "start",
              "value": "0"
            },
            {
              "key": "limit",
              "value": "1000"
            }
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}