Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
-- 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"
-- }
-- ]
-- }
DECLARE @json int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'remoteAddress', '<string>'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'author.type', 'user'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'author.displayName', '<string>'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'author.operations', '<object>'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'author.username', '<string>'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'author.userKey', '<string>'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'creationDate', '<long>'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'summary', '<string>'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'description', '<string>'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'category', '<string>'
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'sysAdmin', 0
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'affectedObject.name', 'amet dolore'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'affectedObject.objectType', 'labore tempor veniam officia'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'changedValues[0].name', 'voluptate sit sed sint '
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'changedValues[0].oldValue', 'proident nisi'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'changedValues[0].newValue', 'dolore aute cupidatat enim'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'changedValues[1].name', 'in eu'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'changedValues[1].oldValue', 'enim laborum tempor Lorem'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'changedValues[1].newValue', 'ipsum ex velit'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'associatedObjects[0].name', 'qui'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'associatedObjects[0].objectType', 'ipsum'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'associatedObjects[1].name', 'nostrud consectetur'
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'associatedObjects[1].objectType', 'sit dolore enim Ut'
EXEC sp_OAMethod @http, 'SetRequestHeader', NULL, 'Content-Type', 'application/json'
DECLARE @resp int
EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://your-domain.atlassian.net/wiki/rest/api/audit', 'application/json', @json
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
RETURN
END
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody
DECLARE @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT
EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
PRINT @sTmp0
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @resp, 'StatusCode', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
END
EXEC @hr = sp_OADestroy @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
DECLARE @name nvarchar(4000)
DECLARE @oldValue nvarchar(4000)
DECLARE @newValue nvarchar(4000)
DECLARE @objectType nvarchar(4000)
DECLARE @v_Type nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'author.type'
DECLARE @DisplayName nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @DisplayName OUT, 'author.displayName'
DECLARE @Operations nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Operations OUT, 'author.operations'
DECLARE @Username nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Username OUT, 'author.username'
DECLARE @UserKey nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @UserKey OUT, 'author.userKey'
DECLARE @remoteAddress nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @remoteAddress OUT, 'remoteAddress'
DECLARE @creationDate int
EXEC sp_OAMethod @jResp, 'IntOf', @creationDate OUT, 'creationDate'
DECLARE @summary nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @summary OUT, 'summary'
DECLARE @description nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @description OUT, 'description'
DECLARE @category nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @category OUT, 'category'
DECLARE @sysAdmin int
EXEC sp_OAMethod @jResp, 'BoolOf', @sysAdmin OUT, 'sysAdmin'
DECLARE @Name nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Name OUT, 'affectedObject.name'
DECLARE @ObjectType nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ObjectType OUT, 'affectedObject.objectType'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'changedValues'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'changedValues[i].name'
EXEC sp_OAMethod @jResp, 'StringOf', @oldValue OUT, 'changedValues[i].oldValue'
EXEC sp_OAMethod @jResp, 'StringOf', @newValue OUT, 'changedValues[i].newValue'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'associatedObjects'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @name OUT, 'associatedObjects[i].name'
EXEC sp_OAMethod @jResp, 'StringOf', @objectType OUT, 'associatedObjects[i].objectType'
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
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": ""
}
]
}