Back to Collection Items
#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>
#include <C_CkStringBuilder.h>
void ChilkatSample(void)
{
HCkHttp http;
BOOL success;
HCkJsonObject json;
HCkHttpResponse resp;
HCkStringBuilder sbResponseBody;
HCkJsonObject jResp;
int respStatusCode;
const char *name;
const char *oldValue;
const char *newValue;
const char *objectType;
const char *v_Type;
const char *DisplayName;
const char *Operations;
const char *Username;
const char *UserKey;
const char *remoteAddress;
int creationDate;
const char *summary;
const char *description;
const char *category;
BOOL sysAdmin;
const char *Name;
const char *ObjectType;
int i;
int count_i;
// 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.
// {
// "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"
// }
// ]
// }
json = CkJsonObject_Create();
CkJsonObject_UpdateString(json,"remoteAddress","<string>");
CkJsonObject_UpdateString(json,"author.type","user");
CkJsonObject_UpdateString(json,"author.displayName","<string>");
CkJsonObject_UpdateString(json,"author.operations","<object>");
CkJsonObject_UpdateString(json,"author.username","<string>");
CkJsonObject_UpdateString(json,"author.userKey","<string>");
CkJsonObject_UpdateString(json,"creationDate","<long>");
CkJsonObject_UpdateString(json,"summary","<string>");
CkJsonObject_UpdateString(json,"description","<string>");
CkJsonObject_UpdateString(json,"category","<string>");
CkJsonObject_UpdateBool(json,"sysAdmin",FALSE);
CkJsonObject_UpdateString(json,"affectedObject.name","amet dolore");
CkJsonObject_UpdateString(json,"affectedObject.objectType","labore tempor veniam officia");
CkJsonObject_UpdateString(json,"changedValues[0].name","voluptate sit sed sint ");
CkJsonObject_UpdateString(json,"changedValues[0].oldValue","proident nisi");
CkJsonObject_UpdateString(json,"changedValues[0].newValue","dolore aute cupidatat enim");
CkJsonObject_UpdateString(json,"changedValues[1].name","in eu");
CkJsonObject_UpdateString(json,"changedValues[1].oldValue","enim laborum tempor Lorem");
CkJsonObject_UpdateString(json,"changedValues[1].newValue","ipsum ex velit");
CkJsonObject_UpdateString(json,"associatedObjects[0].name","qui");
CkJsonObject_UpdateString(json,"associatedObjects[0].objectType","ipsum");
CkJsonObject_UpdateString(json,"associatedObjects[1].name","nostrud consectetur");
CkJsonObject_UpdateString(json,"associatedObjects[1].objectType","sit dolore enim Ut");
CkHttp_SetRequestHeader(http,"Content-Type","application/json");
resp = CkHttp_PostJson3(http,"https://your-domain.atlassian.net/wiki/rest/api/audit","application/json",json);
if (CkHttp_getLastMethodSuccess(http) == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
return;
}
sbResponseBody = CkStringBuilder_Create();
CkHttpResponse_GetBodySb(resp,sbResponseBody);
jResp = CkJsonObject_Create();
CkJsonObject_LoadSb(jResp,sbResponseBody);
CkJsonObject_putEmitCompact(jResp,FALSE);
printf("Response Body:\n");
printf("%s\n",CkJsonObject_emit(jResp));
respStatusCode = CkHttpResponse_getStatusCode(resp);
printf("Response Status Code = %d\n",respStatusCode);
if (respStatusCode >= 400) {
printf("Response Header:\n");
printf("%s\n",CkHttpResponse_header(resp));
printf("Failed.\n");
CkHttpResponse_Dispose(resp);
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(jResp);
return;
}
CkHttpResponse_Dispose(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
// Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
v_Type = CkJsonObject_stringOf(jResp,"author.type");
DisplayName = CkJsonObject_stringOf(jResp,"author.displayName");
Operations = CkJsonObject_stringOf(jResp,"author.operations");
Username = CkJsonObject_stringOf(jResp,"author.username");
UserKey = CkJsonObject_stringOf(jResp,"author.userKey");
remoteAddress = CkJsonObject_stringOf(jResp,"remoteAddress");
creationDate = CkJsonObject_IntOf(jResp,"creationDate");
summary = CkJsonObject_stringOf(jResp,"summary");
description = CkJsonObject_stringOf(jResp,"description");
category = CkJsonObject_stringOf(jResp,"category");
sysAdmin = CkJsonObject_BoolOf(jResp,"sysAdmin");
Name = CkJsonObject_stringOf(jResp,"affectedObject.name");
ObjectType = CkJsonObject_stringOf(jResp,"affectedObject.objectType");
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"changedValues");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
name = CkJsonObject_stringOf(jResp,"changedValues[i].name");
oldValue = CkJsonObject_stringOf(jResp,"changedValues[i].oldValue");
newValue = CkJsonObject_stringOf(jResp,"changedValues[i].newValue");
i = i + 1;
}
i = 0;
count_i = CkJsonObject_SizeOfArray(jResp,"associatedObjects");
while (i < count_i) {
CkJsonObject_putI(jResp,i);
name = CkJsonObject_stringOf(jResp,"associatedObjects[i].name");
objectType = CkJsonObject_stringOf(jResp,"associatedObjects[i].objectType");
i = i + 1;
}
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkStringBuilder_Dispose(sbResponseBody);
CkJsonObject_Dispose(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": ""
}
]
}