Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vJson
Handle hoJson
Variant vResp
Handle hoResp
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJResp
Integer iRespStatusCode
String sName
String sOldValue
String sNewValue
String sObjectType
String sV_Type
String sDisplayName
String sOperations
String sUsername
String sUserKey
String sRemoteAddress
Integer iCreationDate
String sSummary
String sDescription
String sCategory
Boolean iSysAdmin
String sName
String sObjectType
Integer i
Integer iCount_i
String sTemp1
Boolean bTemp1
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// 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"
// }
// ]
// }
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
If (Not(IsComObjectCreated(hoJson))) Begin
Send CreateComObject of hoJson
End
Get ComUpdateString Of hoJson "remoteAddress" "<string>" To iSuccess
Get ComUpdateString Of hoJson "author.type" "user" To iSuccess
Get ComUpdateString Of hoJson "author.displayName" "<string>" To iSuccess
Get ComUpdateString Of hoJson "author.operations" "<object>" To iSuccess
Get ComUpdateString Of hoJson "author.username" "<string>" To iSuccess
Get ComUpdateString Of hoJson "author.userKey" "<string>" To iSuccess
Get ComUpdateString Of hoJson "creationDate" "<long>" To iSuccess
Get ComUpdateString Of hoJson "summary" "<string>" To iSuccess
Get ComUpdateString Of hoJson "description" "<string>" To iSuccess
Get ComUpdateString Of hoJson "category" "<string>" To iSuccess
Get ComUpdateBool Of hoJson "sysAdmin" False To iSuccess
Get ComUpdateString Of hoJson "affectedObject.name" "amet dolore" To iSuccess
Get ComUpdateString Of hoJson "affectedObject.objectType" "labore tempor veniam officia" To iSuccess
Get ComUpdateString Of hoJson "changedValues[0].name" "voluptate sit sed sint " To iSuccess
Get ComUpdateString Of hoJson "changedValues[0].oldValue" "proident nisi" To iSuccess
Get ComUpdateString Of hoJson "changedValues[0].newValue" "dolore aute cupidatat enim" To iSuccess
Get ComUpdateString Of hoJson "changedValues[1].name" "in eu" To iSuccess
Get ComUpdateString Of hoJson "changedValues[1].oldValue" "enim laborum tempor Lorem" To iSuccess
Get ComUpdateString Of hoJson "changedValues[1].newValue" "ipsum ex velit" To iSuccess
Get ComUpdateString Of hoJson "associatedObjects[0].name" "qui" To iSuccess
Get ComUpdateString Of hoJson "associatedObjects[0].objectType" "ipsum" To iSuccess
Get ComUpdateString Of hoJson "associatedObjects[1].name" "nostrud consectetur" To iSuccess
Get ComUpdateString Of hoJson "associatedObjects[1].objectType" "sit dolore enim Ut" To iSuccess
Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"
Get pvComObject of hoJson to vJson
Get ComPostJson3 Of hoHttp "https://your-domain.atlassian.net/wiki/rest/api/audit" "application/json" vJson To vResp
If (IsComObject(vResp)) Begin
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
Set pvComObject Of hoResp To vResp
End
Get ComLastMethodSuccess Of hoHttp To bTemp1
If (bTemp1 = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess
Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
If (Not(IsComObjectCreated(hoJResp))) Begin
Send CreateComObject of hoJResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
Set ComEmitCompact Of hoJResp To False
Showln "Response Body:"
Get ComEmit Of hoJResp To sTemp1
Showln sTemp1
Get ComStatusCode Of hoResp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComHeader Of hoResp To sTemp1
Showln sTemp1
Showln "Failed."
Send Destroy of hoResp
Procedure_Return
End
Send Destroy of hoResp
// 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
Get ComStringOf Of hoJResp "author.type" To sV_Type
Get ComStringOf Of hoJResp "author.displayName" To sDisplayName
Get ComStringOf Of hoJResp "author.operations" To sOperations
Get ComStringOf Of hoJResp "author.username" To sUsername
Get ComStringOf Of hoJResp "author.userKey" To sUserKey
Get ComStringOf Of hoJResp "remoteAddress" To sRemoteAddress
Get ComIntOf Of hoJResp "creationDate" To iCreationDate
Get ComStringOf Of hoJResp "summary" To sSummary
Get ComStringOf Of hoJResp "description" To sDescription
Get ComStringOf Of hoJResp "category" To sCategory
Get ComBoolOf Of hoJResp "sysAdmin" To iSysAdmin
Get ComStringOf Of hoJResp "affectedObject.name" To sName
Get ComStringOf Of hoJResp "affectedObject.objectType" To sObjectType
Move 0 To i
Get ComSizeOfArray Of hoJResp "changedValues" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "changedValues[i].name" To sName
Get ComStringOf Of hoJResp "changedValues[i].oldValue" To sOldValue
Get ComStringOf Of hoJResp "changedValues[i].newValue" To sNewValue
Move (i + 1) To i
Loop
Move 0 To i
Get ComSizeOfArray Of hoJResp "associatedObjects" To iCount_i
While (i < iCount_i)
Set ComI Of hoJResp To i
Get ComStringOf Of hoJResp "associatedObjects[i].name" To sName
Get ComStringOf Of hoJResp "associatedObjects[i].objectType" To sObjectType
Move (i + 1) To i
Loop
End_Procedure
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": ""
}
]
}