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
DECLARE @queryParams int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @queryParams OUT
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'expand', '<string>'
EXEC sp_OAMethod @queryParams, 'UpdateString', @success OUT, 'expand', '<string>'
EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'parentVersion', 0
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
DECLARE @resp int
EXEC sp_OAMethod @http, 'QuickRequestParams', @resp OUT, 'GET', 'https://your-domain.atlassian.net/wiki/rest/api/content/:id/child', @queryParams
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 @queryParams
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 @queryParams
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)
-- {
-- "_expandable": {
-- "attachment": "in ut",
-- "comment": "dolor",
-- "page": "eu exercitation"
-- },
-- "_links": {},
-- "attachment": {
-- "results": [
-- {
-- "value": "<Circular reference to #/components/schemas/Content detected>"
-- },
-- {
-- "value": "<Circular reference to #/components/schemas/Content detected>"
-- }
-- ],
-- "start": -75729038,
-- "limit": 34726306,
-- "size": 18934279,
-- "_links": {}
-- },
-- "comment": {
-- "results": [
-- {
-- "value": "<Circular reference to #/components/schemas/Content detected>"
-- },
-- {
-- "value": "<Circular reference to #/components/schemas/Content detected>"
-- }
-- ],
-- "start": 37994470,
-- "limit": 2587712,
-- "size": -24049554,
-- "_links": {}
-- },
-- "page": {
-- "results": [
-- {
-- "value": "<Circular reference to #/components/schemas/Content detected>"
-- },
-- {
-- "value": "<Circular reference to #/components/schemas/Content detected>"
-- }
-- ],
-- "start": 66843073,
-- "limit": 57682154,
-- "size": -4004438,
-- "_links": {}
-- }
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @value nvarchar(4000)
DECLARE @Attachment nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Attachment OUT, '_expandable.attachment'
DECLARE @Comment nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Comment OUT, '_expandable.comment'
DECLARE @Page nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Page OUT, '_expandable.page'
DECLARE @Start int
EXEC sp_OAMethod @jResp, 'IntOf', @Start OUT, 'attachment.start'
DECLARE @Limit int
EXEC sp_OAMethod @jResp, 'IntOf', @Limit OUT, 'attachment.limit'
DECLARE @Size int
EXEC sp_OAMethod @jResp, 'IntOf', @Size OUT, 'attachment.size'
DECLARE @commentStart int
EXEC sp_OAMethod @jResp, 'IntOf', @commentStart OUT, 'comment.start'
DECLARE @commentLimit int
EXEC sp_OAMethod @jResp, 'IntOf', @commentLimit OUT, 'comment.limit'
DECLARE @commentSize int
EXEC sp_OAMethod @jResp, 'IntOf', @commentSize OUT, 'comment.size'
DECLARE @pageStart int
EXEC sp_OAMethod @jResp, 'IntOf', @pageStart OUT, 'page.start'
DECLARE @pageLimit int
EXEC sp_OAMethod @jResp, 'IntOf', @pageLimit OUT, 'page.limit'
DECLARE @pageSize int
EXEC sp_OAMethod @jResp, 'IntOf', @pageSize OUT, 'page.size'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'attachment.results'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'attachment.results[i].value'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'comment.results'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'comment.results[i].value'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'page.results'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @value OUT, 'page.results[i].value'
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @queryParams
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
Curl Command
curl -G -d "expand=%3Cstring%3E"
-d "expand=%3Cstring%3E"
-d "parentVersion=0"
-H "Authorization: Bearer <access_token>"
https://your-domain.atlassian.net/wiki/rest/api/content/:id/child
Postman Collection Item JSON
{
"name": "Get content children",
"request": {
"auth": {
"type": "oauth2"
},
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/content/:id/child?expand=<string>&expand=<string>&parentVersion=0",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"content",
":id",
"child"
],
"query": [
{
"key": "expand",
"value": "<string>",
"description": "A multi-value parameter indicating which properties of the children to expand, where:\n\n- `attachment` returns all attachments for the content.\n- `comments` returns all comments for the content.\n- `page` returns all child pages of the content."
},
{
"key": "expand",
"value": "<string>",
"description": "A multi-value parameter indicating which properties of the children to expand, where:\n\n- `attachment` returns all attachments for the content.\n- `comments` returns all comments for the content.\n- `page` returns all child pages of the content."
},
{
"key": "parentVersion",
"value": "0",
"description": "The version of the parent content to retrieve children for.\nCurrently, this only works for the latest version."
}
],
"variable": [
{
"key": "id",
"value": "<string>",
"type": "string",
"description": "(Required) The ID of the content to be queried for its children."
}
]
},
"description": "Returns a map of the direct children of a piece of content. A piece of content\nhas different types of child content, depending on its type. These are\nthe default parent-child content type relationships:\n\n- `page`: child content is `page`, `comment`, `attachment`\n- `blogpost`: child content is `comment`, `attachment`\n- `attachment`: child content is `comment`\n- `comment`: child content is `attachment`\n\nApps can override these default relationships. Apps can also introduce\nnew content types that create new parent-child content relationships.\n\nNote, the map will always include all child content types that are valid\nfor the content. However, if the content has no instances of a child content\ntype, the map will contain an empty array for that child content type.\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**: 'View' permission for the space,\nand permission to view the content if it is a page."
},
"response": [
{
"name": "Returned if the requested content children are returned.",
"originalRequest": {
"method": "GET",
"header": [
{
"description": {
"content": "Added as a part of security scheme: oauth2",
"type": "text/plain"
},
"key": "Authorization",
"value": "<token>"
}
],
"url": {
"raw": "{{baseUrl}}/api/content/:id/child?expand=<string>&expand=<string>&parentVersion=0",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"content",
":id",
"child"
],
"query": [
{
"key": "expand",
"value": "<string>"
},
{
"key": "expand",
"value": "<string>"
},
{
"key": "parentVersion",
"value": "0"
}
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"_expandable\": {\n \"attachment\": \"in ut\",\n \"comment\": \"dolor\",\n \"page\": \"eu exercitation\"\n },\n \"_links\": {},\n \"attachment\": {\n \"results\": [\n {\n \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n },\n {\n \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n }\n ],\n \"start\": -75729038,\n \"limit\": 34726306,\n \"size\": 18934279,\n \"_links\": {}\n },\n \"comment\": {\n \"results\": [\n {\n \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n },\n {\n \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n }\n ],\n \"start\": 37994470,\n \"limit\": 2587712,\n \"size\": -24049554,\n \"_links\": {}\n },\n \"page\": {\n \"results\": [\n {\n \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n },\n {\n \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n }\n ],\n \"start\": 66843073,\n \"limit\": 57682154,\n \"size\": -4004438,\n \"_links\": {}\n }\n}"
},
{
"name": "Returned if;\n\n- There is no content with the given ID.\n- The calling user does not have permission to view the content.",
"originalRequest": {
"method": "GET",
"header": [
{
"description": {
"content": "Added as a part of security scheme: oauth2",
"type": "text/plain"
},
"key": "Authorization",
"value": "<token>"
}
],
"url": {
"raw": "{{baseUrl}}/api/content/:id/child?expand=<string>&expand=<string>&parentVersion=0",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"content",
":id",
"child"
],
"query": [
{
"key": "expand",
"value": "<string>"
},
{
"key": "expand",
"value": "<string>"
},
{
"key": "parentVersion",
"value": "0"
}
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
}
]
}