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, 'start', 0
EXEC sp_OAMethod @queryParams, 'UpdateInt', @success OUT, 'limit', 100
-- 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/restriction', @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)
-- {
-- "results": [
-- {
-- "operation": "copy",
-- "_expandable": {
-- "restrictions": "incididunt anim ut id nulla",
-- "content": "cupidatat"
-- },
-- "_links": {},
-- "restrictions": {
-- "user": {
-- "results": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "start": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "limit": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "size": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- }
-- },
-- "group": {
-- "results": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "start": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "limit": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "size": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- }
-- },
-- "_expandable": {
-- "user": "et laborum",
-- "group": "qui consequat"
-- }
-- },
-- "content": {
-- "value": "<Circular reference to #/components/schemas/Content detected>"
-- }
-- },
-- {
-- "operation": "copy",
-- "_expandable": {
-- "restrictions": "ullamco velit Lorem",
-- "content": "culpa esse sit anim aliqua"
-- },
-- "_links": {},
-- "restrictions": {
-- "user": {
-- "results": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "start": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "limit": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "size": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- }
-- },
-- "group": {
-- "results": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "start": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "limit": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- },
-- "size": {
-- "value": "<Error: Too many levels of nesting to fake this schema>"
-- }
-- },
-- "_expandable": {
-- "user": "ut",
-- "group": "ad Ut"
-- }
-- },
-- "content": {
-- "value": "<Circular reference to #/components/schemas/Content detected>"
-- }
-- }
-- ],
-- "start": 8238998,
-- "limit": -43753388,
-- "size": -64805454,
-- "restrictionsHash": "ut commodo",
-- "_links": {}
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @operation nvarchar(4000)
DECLARE @Restrictions nvarchar(4000)
DECLARE @Content nvarchar(4000)
DECLARE @Value nvarchar(4000)
DECLARE @StartValue nvarchar(4000)
DECLARE @LimitValue nvarchar(4000)
DECLARE @SizeValue nvarchar(4000)
DECLARE @ResultsValue nvarchar(4000)
DECLARE @User nvarchar(4000)
DECLARE @Group nvarchar(4000)
DECLARE @contentValue nvarchar(4000)
DECLARE @start int
EXEC sp_OAMethod @jResp, 'IntOf', @start OUT, 'start'
DECLARE @limit int
EXEC sp_OAMethod @jResp, 'IntOf', @limit OUT, 'limit'
DECLARE @size int
EXEC sp_OAMethod @jResp, 'IntOf', @size OUT, 'size'
DECLARE @restrictionsHash nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @restrictionsHash OUT, 'restrictionsHash'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'results'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @operation OUT, 'results[i].operation'
EXEC sp_OAMethod @jResp, 'StringOf', @Restrictions OUT, 'results[i]._expandable.restrictions'
EXEC sp_OAMethod @jResp, 'StringOf', @Content OUT, 'results[i]._expandable.content'
EXEC sp_OAMethod @jResp, 'StringOf', @Value OUT, 'results[i].restrictions.user.results.value'
EXEC sp_OAMethod @jResp, 'StringOf', @StartValue OUT, 'results[i].restrictions.user.start.value'
EXEC sp_OAMethod @jResp, 'StringOf', @LimitValue OUT, 'results[i].restrictions.user.limit.value'
EXEC sp_OAMethod @jResp, 'StringOf', @SizeValue OUT, 'results[i].restrictions.user.size.value'
EXEC sp_OAMethod @jResp, 'StringOf', @ResultsValue OUT, 'results[i].restrictions.group.results.value'
EXEC sp_OAMethod @jResp, 'StringOf', @StartValue OUT, 'results[i].restrictions.group.start.value'
EXEC sp_OAMethod @jResp, 'StringOf', @LimitValue OUT, 'results[i].restrictions.group.limit.value'
EXEC sp_OAMethod @jResp, 'StringOf', @SizeValue OUT, 'results[i].restrictions.group.size.value'
EXEC sp_OAMethod @jResp, 'StringOf', @User OUT, 'results[i].restrictions._expandable.user'
EXEC sp_OAMethod @jResp, 'StringOf', @Group OUT, 'results[i].restrictions._expandable.group'
EXEC sp_OAMethod @jResp, 'StringOf', @contentValue OUT, 'results[i].content.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 "start=0"
-d "limit=100"
-H "Authorization: Bearer <access_token>"
https://your-domain.atlassian.net/wiki/rest/api/content/:id/restriction
Postman Collection Item JSON
{
"name": "Get restrictions",
"request": {
"auth": {
"type": "oauth2"
},
"method": "GET",
"header": [
],
"url": {
"raw": "{{baseUrl}}/api/content/:id/restriction?expand=<string>&expand=<string>&start=0&limit=100",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"content",
":id",
"restriction"
],
"query": [
{
"key": "expand",
"value": "<string>",
"description": "A multi-value parameter indicating which properties of the content\nrestrictions to expand. By default, the following objects are expanded:\n`restrictions.user`, `restrictions.group`.\n\n- `restrictions.user` returns the piece of content that the restrictions are\napplied to.\n- `restrictions.group` returns the piece of content that the restrictions are\napplied to.\n- `content` returns the piece of content that the restrictions are\napplied to."
},
{
"key": "expand",
"value": "<string>",
"description": "A multi-value parameter indicating which properties of the content\nrestrictions to expand. By default, the following objects are expanded:\n`restrictions.user`, `restrictions.group`.\n\n- `restrictions.user` returns the piece of content that the restrictions are\napplied to.\n- `restrictions.group` returns the piece of content that the restrictions are\napplied to.\n- `content` returns the piece of content that the restrictions are\napplied to."
},
{
"key": "start",
"value": "0",
"description": "The starting index of the users and groups in the returned restrictions."
},
{
"key": "limit",
"value": "100",
"description": "The maximum number of users and the maximum number of groups, in the\nreturned restrictions, to return per page. Note, this may be restricted\nby fixed system limits."
}
],
"variable": [
{
"key": "id",
"value": "<string>",
"type": "string",
"description": "(Required) The ID of the content to be queried for its restrictions."
}
]
},
"description": "Returns the restrictions on a piece of content.\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\nPermission to view the content."
},
"response": [
{
"name": "Returned if the requested restrictions 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/restriction?expand=<string>&expand=<string>&start=0&limit=100",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"content",
":id",
"restriction"
],
"query": [
{
"key": "expand",
"value": "<string>"
},
{
"key": "expand",
"value": "<string>"
},
{
"key": "start",
"value": "0"
},
{
"key": "limit",
"value": "100"
}
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [
],
"body": "{\n \"results\": [\n {\n \"operation\": \"copy\",\n \"_expandable\": {\n \"restrictions\": \"incididunt anim ut id nulla\",\n \"content\": \"cupidatat\"\n },\n \"_links\": {},\n \"restrictions\": {\n \"user\": {\n \"results\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"start\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"limit\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"size\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"group\": {\n \"results\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"start\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"limit\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"size\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"_expandable\": {\n \"user\": \"et laborum\",\n \"group\": \"qui consequat\"\n }\n },\n \"content\": {\n \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n }\n },\n {\n \"operation\": \"copy\",\n \"_expandable\": {\n \"restrictions\": \"ullamco velit Lorem\",\n \"content\": \"culpa esse sit anim aliqua\"\n },\n \"_links\": {},\n \"restrictions\": {\n \"user\": {\n \"results\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"start\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"limit\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"size\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"group\": {\n \"results\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"start\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"limit\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n },\n \"size\": {\n \"value\": \"<Error: Too many levels of nesting to fake this schema>\"\n }\n },\n \"_expandable\": {\n \"user\": \"ut\",\n \"group\": \"ad Ut\"\n }\n },\n \"content\": {\n \"value\": \"<Circular reference to #/components/schemas/Content detected>\"\n }\n }\n ],\n \"start\": 8238998,\n \"limit\": -43753388,\n \"size\": -64805454,\n \"restrictionsHash\": \"ut commodo\",\n \"_links\": {}\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/restriction?expand=<string>&expand=<string>&start=0&limit=100",
"host": [
"{{baseUrl}}"
],
"path": [
"api",
"content",
":id",
"restriction"
],
"query": [
{
"key": "expand",
"value": "<string>"
},
{
"key": "expand",
"value": "<string>"
},
{
"key": "start",
"value": "0"
},
{
"key": "limit",
"value": "100"
}
],
"variable": [
{
"key": "id"
}
]
}
},
"status": "Not Found",
"code": 404,
"_postman_previewlanguage": "text",
"header": [
{
"key": "Content-Type",
"value": "text/plain"
}
],
"cookie": [
],
"body": ""
}
]
}