Chilkat Online Tools

SQL Server / Atlassian Confluence Cloud / Get content restriction status for group

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
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    DECLARE @success int

    -- Adds the "Authorization: Bearer <access_token>" header.
    EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'

    DECLARE @sbResponseBody int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbResponseBody OUT

    EXEC sp_OAMethod @http, 'QuickGetSb', @success OUT, 'https://your-domain.atlassian.net/wiki/rest/api/content/:id/restriction/byOperation/:operationKey/byGroupId/:groupId', @sbResponseBody
    IF @success = 0
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @sbResponseBody
        RETURN
      END


    EXEC sp_OAGetProperty @http, 'LastStatus', @iTmp0 OUT
    PRINT 'Response status code = ' + @iTmp0
    EXEC sp_OAMethod @sbResponseBody, 'GetAsString', @sTmp0 OUT
    PRINT @sTmp0

    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @sbResponseBody


END
GO

Curl Command

curl -X GET
	-H "Authorization: Bearer <access_token>"
https://your-domain.atlassian.net/wiki/rest/api/content/:id/restriction/byOperation/:operationKey/byGroupId/:groupId

Postman Collection Item JSON

{
  "name": "Get content restriction status for group",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/content/:id/restriction/byOperation/:operationKey/byGroupId/:groupId",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "content",
        ":id",
        "restriction",
        "byOperation",
        ":operationKey",
        "byGroupId",
        ":groupId"
      ],
      "variable": [
        {
          "key": "id",
          "value": "<string>",
          "type": "string",
          "description": "(Required) The ID of the content that the restriction applies to."
        },
        {
          "key": "operationKey",
          "value": "<string>",
          "type": "string",
          "description": "(Required) The operation that the restriction applies to."
        },
        {
          "key": "groupId",
          "value": "<string>",
          "type": "string",
          "description": "(Required) The id of the group to be queried for whether the content restriction\napplies to it."
        }
      ]
    },
    "description": "Returns whether the specified content restriction applies to a group.\nFor example, if a page with `id=123` has a `read` restriction for the `123456` group id,\nthe following request will return `true`:\n\n`https://your-domain.atlassian.net/wiki/rest/api/content/123/restriction/byOperation/read/byGroupId/123456`\n\nNote that a response of `true` does not guarantee that the group can view the page, as it does not account for\naccount-inherited restrictions, space permissions, or even product access. For more\ninformation, see [Confluence permissions](https://confluence.atlassian.com/x/_AozKw).\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\nPermission to view the content."
  },
  "response": [
    {
      "name": "Returns true if the content restriction applies to the group. The response\nwill not return a response body.",
      "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/byOperation/:operationKey/byGroupId/:groupId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "content",
            ":id",
            "restriction",
            "byOperation",
            ":operationKey",
            "byGroupId",
            ":groupId"
          ],
          "variable": [
            {
              "key": "id"
            },
            {
              "key": "operationKey"
            },
            {
              "key": "groupId"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Returned if the calling user does not have permission to view the\ncontent.",
      "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/byOperation/:operationKey/byGroupId/:groupId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "content",
            ":id",
            "restriction",
            "byOperation",
            ":operationKey",
            "byGroupId",
            ":groupId"
          ],
          "variable": [
            {
              "key": "id"
            },
            {
              "key": "operationKey"
            },
            {
              "key": "groupId"
            }
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Returned if\n- There is no content with the given ID.\n- An invalid operation or group is specified.\n- Given groupId is blank or has invalid characters",
      "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/byOperation/:operationKey/byGroupId/:groupId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "content",
            ":id",
            "restriction",
            "byOperation",
            ":operationKey",
            "byGroupId",
            ":groupId"
          ],
          "variable": [
            {
              "key": "id"
            },
            {
              "key": "operationKey"
            },
            {
              "key": "groupId"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}