Update workbook share permissions
/api/20210901/catalog/workbooks/{id}/actions/updateSharePermissions
Request
-
id(required): string
Catalog item ID in base64url format.
- application/json
Response
- application/json
200 Response
400 Response
object-
code(required): string
Short error code that defines the error, meant for programmatic parsing.
-
message(required): string
Human-readable error string.
401 Response
object-
code(required): string
Short error code that defines the error, meant for programmatic parsing.
-
message(required): string
Human-readable error string.
403 Response
object-
code(required): string
Short error code that defines the error, meant for programmatic parsing.
-
message(required): string
Human-readable error string.
404 Response
object-
code(required): string
Short error code that defines the error, meant for programmatic parsing.
-
message(required): string
Human-readable error string.
500 Response
object-
code(required): string
Short error code that defines the error, meant for programmatic parsing.
-
message(required): string
Human-readable error string.
Examples
- Example 1 - Update workbook share permissions for a specific user (or application role)
- Example 2 - Replace all existing share permissions for a workbook
- Example 3 - Delete workbook share permissions for a specific user (or application role)
Example 1 - Update workbook share permissions for a specific user
In this example, you update share permissions for a workbook with the object ID /shared/Sales/MySalesWorkbook. The Base64URL-safe encoded ID value for this workbook is L3NoYXJlZC9TYWxlcy9NeVNhbGVzV29ya2Jvb2s. You use the ReplaceMatchingAccounts update mode to update the permissions for a specified account (Jane Doe) and preserve existing permissions for accounts not included in the request.
You can get the ID of a workbook by using Get catalog items by type.
cURL Example:
curl -i \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--request POST \
--data '{
"updateMode": "ReplaceMatchingAccounts",
"sharePermissions": [
{
"accountGuid": "jane.doe@example.com",
"accountType": "User",
"permissions": {
"view": true,
"edit": false
}
}
]
}' \
'https://<hostname>/api/20210901/catalog/workbooks/L3NoYXJlZC9TYWxlcy9NeVNhbGVzV29ya2Jvb2s/actions/updateSharePermissions'
Example of Request Body
{
"updateMode": "ReplaceMatchingAccounts",
"sharePermissions": [
{
"accountGuid": "jane.doe@example.com",
"accountType": "User",
"permissions": {
"view": true,
"edit": false
}
}
]
}Example of Response Body
[
{
"accountGuid": "jane.doe@example.com",
"accountType": "User",
"accountDisplayName": "Jane Doe",
"permissions": {
"view": true,
"edit": false
}
}
]Example 2 - Replace all existing share permissions for a workbook
In this example, you use the ReplaceAll update mode to remove all existing share permissions for a workbook with the object ID /shared/Sales/MySalesWorkbook. The Base64URL-safe encoded ID value for this workbook is L3NoYXJlZC9TYWxlcy9NeVNhbGVzV29ya2Jvb2s. You specify the new permissions in the same request, for example you give the user Jane Doe view-only access and users with the Sales application role view and edit access.
You can get the ID of a workbook by using Get catalog items by type.
cURL Example:
curl -i \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--request POST \
--data '{
"updateMode": "ReplaceAll",
"sharePermissions": [
{
"accountGuid": "jane.doe@example.com",
"accountType": "User",
"permissions": {
"view": true,
"edit": false
}
},
{
"accountGuid": "Sales",
"accountType": "ApplicationRole",
"permissions": {
"view": true,
"edit": true
}
}
]
}' \
'https://<hostname>/api/20210901/catalog/workbooks/L3NoYXJlZC9TYWxlcy9NeVNhbGVzV29ya2Jvb2s/actions/updateSharePermissions'Example of Request Body
{
"updateMode": "ReplaceAll",
"sharePermissions": [
{
"accountGuid": "jane.doe@example.com",
"accountType": "User",
"permissions": {
"view": true,
"edit": false
}
},
{
"accountGuid": "Sales",
"accountType": "ApplicationRole",
"permissions": {
"view": true,
"edit": true
}
}
]
}Example of Response Body
[
{
"accountGuid": "jane.doe@example.com",
"accountType": "User",
"accountDisplayName": "Jane Doe",
"permissions": {
"view": true,
"edit": false
}
},
{
"accountGuid": "Sales",
"accountType": "ApplicationRole",
"accountDisplayName": "Sales",
"permissions": {
"view": true,
"edit": true
}
}
]Example 3 - Delete workbook share permissions for a specific user or application role
In this example, you use the DeleteMatchingAccounts update mode to remove the share permissions for a specific user (Jane Doe) and application role (Sales). With DeleteMatchingAccounts, you omit the permissions property.
cURL Example:
curl -i \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--request POST \
--data '{
"updateMode": "DeleteMatchingAccounts",
"sharePermissions": [
{
"accountGuid": "jane.doe",
"accountType": "User"
},
{
"accountGuid": "Sales",
"accountType": "ApplicationRole"
}
]
}' \
'https://<hostname>/api/20210901/catalog/workbooks/L3NoYXJlZC9TYWxlcy9NeVNhbGVzV29ya2Jvb2s/actions/updateSharePermissions'
Example of Request Body
{
"updateMode": "DeleteMatchingAccounts",
"sharePermissions": [
{
"accountGuid": "jane.doe",
"accountType": "User"
},
{
"accountGuid": "Sales",
"accountType": "ApplicationRole"
}
]
}Example of Response Body
If these are the workbook’s only share permissions, the response is an empty array:
[]