Chilkat Online Tools

PowerBuilder / Atlassian Confluence Cloud / Create audit record

Back to Collection Items

integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_Json
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JResp
integer li_RespStatusCode
string ls_Name
string ls_OldValue
string ls_NewValue
string ls_ObjectType
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 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
li_rc = loo_Http.ConnectToNewObject("Chilkat_9_5_0.Http")
if li_rc < 0 then
    destroy loo_Http
    MessageBox("Error","Connecting to COM object failed")
    return
end if

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

// The following JSON is sent in the request body.

// {
//   "remoteAddress": "<string>",
//   "author": {
//     "type": "user",
//     "displayName": "<string>",
//     "operations": "<object>",
//     "username": "<string>",
//     "userKey": "<string>"
//   },
//   "creationDate": "<long>",
//   "summary": "<string>",
//   "description": "<string>",
//   "category": "<string>",
//   "sysAdmin": false,
//   "affectedObject": {
//     "name": "amet dolore",
//     "objectType": "labore tempor veniam officia"
//   },
//   "changedValues": [
//     {
//       "name": "voluptate sit sed sint ",
//       "oldValue": "proident nisi",
//       "newValue": "dolore aute cupidatat enim"
//     },
//     {
//       "name": "in eu",
//       "oldValue": "enim laborum tempor Lorem",
//       "newValue": "ipsum ex velit"
//     }
//   ],
//   "associatedObjects": [
//     {
//       "name": "qui",
//       "objectType": "ipsum"
//     },
//     {
//       "name": "nostrud consectetur",
//       "objectType": "sit dolore enim Ut"
//     }
//   ]
// }

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_Json.UpdateString("remoteAddress","<string>")
loo_Json.UpdateString("author.type","user")
loo_Json.UpdateString("author.displayName","<string>")
loo_Json.UpdateString("author.operations","<object>")
loo_Json.UpdateString("author.username","<string>")
loo_Json.UpdateString("author.userKey","<string>")
loo_Json.UpdateString("creationDate","<long>")
loo_Json.UpdateString("summary","<string>")
loo_Json.UpdateString("description","<string>")
loo_Json.UpdateString("category","<string>")
loo_Json.UpdateBool("sysAdmin",0)
loo_Json.UpdateString("affectedObject.name","amet dolore")
loo_Json.UpdateString("affectedObject.objectType","labore tempor veniam officia")
loo_Json.UpdateString("changedValues[0].name","voluptate sit sed sint ")
loo_Json.UpdateString("changedValues[0].oldValue","proident nisi")
loo_Json.UpdateString("changedValues[0].newValue","dolore aute cupidatat enim")
loo_Json.UpdateString("changedValues[1].name","in eu")
loo_Json.UpdateString("changedValues[1].oldValue","enim laborum tempor Lorem")
loo_Json.UpdateString("changedValues[1].newValue","ipsum ex velit")
loo_Json.UpdateString("associatedObjects[0].name","qui")
loo_Json.UpdateString("associatedObjects[0].objectType","ipsum")
loo_Json.UpdateString("associatedObjects[1].name","nostrud consectetur")
loo_Json.UpdateString("associatedObjects[1].objectType","sit dolore enim Ut")

loo_Http.SetRequestHeader("Content-Type","application/json")

loo_Resp = loo_Http.PostJson3("https://your-domain.atlassian.net/wiki/rest/api/audit","application/json",loo_Json)
if loo_Http.LastMethodSuccess = 0 then
    Write-Debug loo_Http.LastErrorText
    destroy loo_Http
    destroy loo_Json
    return
end if

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Resp.GetBodySb(loo_SbResponseBody)

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.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_Json
    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)

// {
//   "author": {
//     "type": "user",
//     "displayName": "dolore do consectetur veniam",
//     "operations": null,
//     "username": "adipisicing nostrud ullamco",
//     "userKey": "eu in"
//   },
//   "remoteAddress": "ea Duis minim p",
//   "creationDate": -62196571,
//   "summary": "laboris",
//   "description": "dolor est sed non officia",
//   "category": "eiusmod ut nulla",
//   "sysAdmin": false,
//   "affectedObject": {
//     "name": "sint eu labore magna fugiat",
//     "objectType": "ut exercitation"
//   },
//   "changedValues": [
//     {
//       "name": "ut ea occaecat ex cupidatat",
//       "oldValue": "ipsum minim Duis",
//       "newValue": "esse cupidatat ad"
//     },
//     {
//       "name": "fugiat est enim deserunt commodo",
//       "oldValue": "quis ipsum",
//       "newValue": "occaecat Lorem"
//     }
//   ],
//   "associatedObjects": [
//     {
//       "name": "in es",
//       "objectType": "ut reprehenderit mollit exercitation"
//     },
//     {
//       "name": "velit culpa eiusmod",
//       "objectType": "tempor"
//     }
//   ]
// }

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

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


destroy loo_Http
destroy loo_Json
destroy loo_SbResponseBody
destroy loo_JResp

Curl Command

curl -X POST
	-H "Content-Type: application/json"
	-d '{
    "remoteAddress": "<string>",
    "author": {
        "type": "user",
        "displayName": "<string>",
        "operations": "<object>",
        "username": "<string>",
        "userKey": "<string>"
    },
    "creationDate": "<long>",
    "summary": "<string>",
    "description": "<string>",
    "category": "<string>",
    "sysAdmin": false,
    "affectedObject": {
        "name": "amet dolore",
        "objectType": "labore tempor veniam officia"
    },
    "changedValues": [
        {
            "name": "voluptate sit sed sint ",
            "oldValue": "proident nisi",
            "newValue": "dolore aute cupidatat enim"
        },
        {
            "name": "in eu",
            "oldValue": "enim laborum tempor Lorem",
            "newValue": "ipsum ex velit"
        }
    ],
    "associatedObjects": [
        {
            "name": "qui",
            "objectType": "ipsum"
        },
        {
            "name": "nostrud consectetur",
            "objectType": "sit dolore enim Ut"
        }
    ]
}'
https://your-domain.atlassian.net/wiki/rest/api/audit

Postman Collection Item JSON

{
  "name": "Create audit record",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n    \"remoteAddress\": \"<string>\",\n    \"author\": {\n        \"type\": \"user\",\n        \"displayName\": \"<string>\",\n        \"operations\": \"<object>\",\n        \"username\": \"<string>\",\n        \"userKey\": \"<string>\"\n    },\n    \"creationDate\": \"<long>\",\n    \"summary\": \"<string>\",\n    \"description\": \"<string>\",\n    \"category\": \"<string>\",\n    \"sysAdmin\": false,\n    \"affectedObject\": {\n        \"name\": \"amet dolore\",\n        \"objectType\": \"labore tempor veniam officia\"\n    },\n    \"changedValues\": [\n        {\n            \"name\": \"voluptate sit sed sint \",\n            \"oldValue\": \"proident nisi\",\n            \"newValue\": \"dolore aute cupidatat enim\"\n        },\n        {\n            \"name\": \"in eu\",\n            \"oldValue\": \"enim laborum tempor Lorem\",\n            \"newValue\": \"ipsum ex velit\"\n        }\n    ],\n    \"associatedObjects\": [\n        {\n            \"name\": \"qui\",\n            \"objectType\": \"ipsum\"\n        },\n        {\n            \"name\": \"nostrud consectetur\",\n            \"objectType\": \"sit dolore enim Ut\"\n        }\n    ]\n}"
    },
    "url": {
      "raw": "{{baseUrl}}/api/audit",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "audit"
      ]
    },
    "description": "Creates a record in the audit log.\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\n'Confluence Administrator' global permission."
  },
  "response": [
    {
      "name": "Returned if the record is created in the audit log.",
      "originalRequest": {
        "method": "POST",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"remoteAddress\": \"<string>\",\n    \"author\": {\n        \"type\": \"user\",\n        \"displayName\": \"<string>\",\n        \"operations\": \"<object>\",\n        \"username\": \"<string>\",\n        \"userKey\": \"<string>\"\n    },\n    \"creationDate\": \"<long>\",\n    \"summary\": \"<string>\",\n    \"description\": \"<string>\",\n    \"category\": \"<string>\",\n    \"sysAdmin\": false,\n    \"affectedObject\": {\n        \"name\": \"ut Lorem reprehenderit dolore tempor\",\n        \"objectType\": \"magna consectetur\"\n    },\n    \"changedValues\": [\n        {\n            \"name\": \"in\",\n            \"oldValue\": \"nisi cillum eiusmod exercitation\",\n            \"newValue\": \"in nulla adipisicing ni\"\n        },\n        {\n            \"name\": \"esse ea\",\n            \"oldValue\": \"mollit elit laborum\",\n            \"newValue\": \"sint ut nisi elit\"\n        }\n    ],\n    \"associatedObjects\": [\n        {\n            \"name\": \"veniam qui\",\n            \"objectType\": \"magna laborum mollit\"\n        },\n        {\n            \"name\": \"sit tempor ad id adipisicing\",\n            \"objectType\": \"reprehenderit Duis est ex commodo\"\n        }\n    ]\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/audit",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "audit"
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"author\": {\n  \"type\": \"user\",\n  \"displayName\": \"dolore do consectetur veniam\",\n  \"operations\": null,\n  \"username\": \"adipisicing nostrud ullamco\",\n  \"userKey\": \"eu in\"\n },\n \"remoteAddress\": \"ea Duis minim p\",\n \"creationDate\": -62196571,\n \"summary\": \"laboris\",\n \"description\": \"dolor est sed non officia\",\n \"category\": \"eiusmod ut nulla\",\n \"sysAdmin\": false,\n \"affectedObject\": {\n  \"name\": \"sint eu labore magna fugiat\",\n  \"objectType\": \"ut exercitation\"\n },\n \"changedValues\": [\n  {\n   \"name\": \"ut ea occaecat ex cupidatat\",\n   \"oldValue\": \"ipsum minim Duis\",\n   \"newValue\": \"esse cupidatat ad\"\n  },\n  {\n   \"name\": \"fugiat est enim deserunt commodo\",\n   \"oldValue\": \"quis ipsum\",\n   \"newValue\": \"occaecat Lorem\"\n  }\n ],\n \"associatedObjects\": [\n  {\n   \"name\": \"in es\",\n   \"objectType\": \"ut reprehenderit mollit exercitation\"\n  },\n  {\n   \"name\": \"velit culpa eiusmod\",\n   \"objectType\": \"tempor\"\n  }\n ]\n}"
    },
    {
      "name": "Returned if the `remoteAddress` property is not specified.",
      "originalRequest": {
        "method": "POST",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"remoteAddress\": \"<string>\",\n    \"author\": {\n        \"type\": \"user\",\n        \"displayName\": \"<string>\",\n        \"operations\": \"<object>\",\n        \"username\": \"<string>\",\n        \"userKey\": \"<string>\"\n    },\n    \"creationDate\": \"<long>\",\n    \"summary\": \"<string>\",\n    \"description\": \"<string>\",\n    \"category\": \"<string>\",\n    \"sysAdmin\": false,\n    \"affectedObject\": {\n        \"name\": \"ut Lorem reprehenderit dolore tempor\",\n        \"objectType\": \"magna consectetur\"\n    },\n    \"changedValues\": [\n        {\n            \"name\": \"in\",\n            \"oldValue\": \"nisi cillum eiusmod exercitation\",\n            \"newValue\": \"in nulla adipisicing ni\"\n        },\n        {\n            \"name\": \"esse ea\",\n            \"oldValue\": \"mollit elit laborum\",\n            \"newValue\": \"sint ut nisi elit\"\n        }\n    ],\n    \"associatedObjects\": [\n        {\n            \"name\": \"veniam qui\",\n            \"objectType\": \"magna laborum mollit\"\n        },\n        {\n            \"name\": \"sit tempor ad id adipisicing\",\n            \"objectType\": \"reprehenderit Duis est ex commodo\"\n        }\n    ]\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/api/audit",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "audit"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}