Chilkat Online Tools

C# / Atlassian Confluence Cloud / Get content restriction status for user

Back to Collection Items

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

Chilkat.Http http = new Chilkat.Http();
bool success;

Chilkat.JsonObject queryParams = new Chilkat.JsonObject();
queryParams.UpdateString("key","<string>");
queryParams.UpdateString("userName","<string>");
queryParams.UpdateString("accountId","<string>");

// Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken = "<access_token>";

Chilkat.HttpResponse resp = http.QuickRequestParams("GET","https://your-domain.atlassian.net/wiki/rest/api/content/:id/restriction/byOperation/:operationKey/user",queryParams);
if (http.LastMethodSuccess == false) {
    Debug.WriteLine(http.LastErrorText);
    return;
}

Debug.WriteLine(Convert.ToString(resp.StatusCode));
Debug.WriteLine(resp.BodyStr);

Curl Command

curl -G -d "key=%3Cstring%3E"
	-d "userName=%3Cstring%3E"
	-d "accountId=%3Cstring%3E"
	-H "Authorization: Bearer <access_token>"
https://your-domain.atlassian.net/wiki/rest/api/content/:id/restriction/byOperation/:operationKey/user

Postman Collection Item JSON

{
  "name": "Get content restriction status for user",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "GET",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/content/:id/restriction/byOperation/:operationKey/user?key=<string>&userName=<string>&accountId=<string>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "content",
        ":id",
        "restriction",
        "byOperation",
        ":operationKey",
        "user"
      ],
      "query": [
        {
          "key": "key",
          "value": "<string>",
          "description": "This parameter is no longer available and will be removed from the documentation soon.\nUse `accountId` instead.\nSee the [deprecation notice](/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/) for details."
        },
        {
          "key": "userName",
          "value": "<string>",
          "description": "This parameter is no longer available and will be removed from the documentation soon.\nUse `accountId` instead.\nSee the [deprecation notice](/cloud/confluence/deprecation-notice-user-privacy-api-migration-guide/) for details."
        },
        {
          "key": "accountId",
          "value": "<string>",
          "description": "(Required) The account ID of the user to be queried for whether the content restriction applies to it. The accountId\nuniquely identifies the user across all Atlassian products. For example, `384093:32b4d9w0-f6a5-3535-11a3-9c8c88d10192`."
        }
      ],
      "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 is restricted."
        }
      ]
    },
    "description": "Returns whether the specified content restriction applies to a user.\nFor example, if a page with `id=123` has a `read` restriction for a user with an account ID of\n`384093:32b4d9w0-f6a5-3535-11a3-9c8c88d10192`, the following request will return `true`:\n\n`https://your-domain.atlassian.net/wiki/rest/api/content/123/restriction/byOperation/read/user?accountId=384093:32b4d9w0-f6a5-3535-11a3-9c8c88d10192`\n\nNote that a response of `true` does not guarantee that the user 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": "Return true if the content restriction applies to the user. The response\nbody will be empty.",
      "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/user?key=<string>&userName=<string>&accountId=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "content",
            ":id",
            "restriction",
            "byOperation",
            ":operationKey",
            "user"
          ],
          "query": [
            {
              "key": "key",
              "value": "<string>"
            },
            {
              "key": "userName",
              "value": "<string>"
            },
            {
              "key": "accountId",
              "value": "<string>"
            }
          ],
          "variable": [
            {
              "key": "id"
            },
            {
              "key": "operationKey"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "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.\n- An invalid operation or user is specified.",
      "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/user?key=<string>&userName=<string>&accountId=<string>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "content",
            ":id",
            "restriction",
            "byOperation",
            ":operationKey",
            "user"
          ],
          "query": [
            {
              "key": "key",
              "value": "<string>"
            },
            {
              "key": "userName",
              "value": "<string>"
            },
            {
              "key": "accountId",
              "value": "<string>"
            }
          ],
          "variable": [
            {
              "key": "id"
            },
            {
              "key": "operationKey"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}