Hi
I couldn't find anywhere how I can add or remove page restrictions for user and group by using Python ?
It can be any API( xmlrpc or REST API), just help me to do that ?
potentially I just need to remove all permission for everybody and then add only for one user
Hi Gurgen,
You can see the XMLRPC documentation for setting permissions here, specifically setContentPermissions:
https://developer.atlassian.com/server/confluence/remote-confluence-methods/#permissions
If you search for some further XMLRPC examples, they shouldn't be too hard to find.
And in case someone is curious about the Cloud version, you can already set page permissions via REST:
https://developer.atlassian.com/cloud/confluence/rest/#api-content-id-restriction-put
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Stephen
Thank you very much.
Is there a way to do this by REST API ? seems that feature is in experimental API. I found one way, but that is still in 'experimental' s
PUT https://confluence/rest/experimental/content/<id>/restriction/byOperation/read/user?userName=billgates
So I am worried whether I can use xmlrpc deprecated method for customers. How long this is going to be supported in XMLRPC ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gurgen,
I don't know how to remove restrictions using the Python with the REST API. Based on the Confluence REST API Documentation it looks like the API will let you GET the restrictions but does not provide a way to update them.
Please consider SQL as an alternative, as described in: How to remove all restrictions from a specific page via the database.
Thanks,
Ann
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks I have found that, but I don't need DB.
any suggestion, by using xmlrpc ? anyway ? if you provide me API I can write Python code myself. I need to do that in Python.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
most prob you can update the permissions and that should remove whatever you needed.
you can omit the group or user if you don't require to update either one of them
url = 'https://your-confluence.com/rest/experimental/content/{id}/restriction'
headers = { "Accept": "application/json", "Content-Type": "application/json" }
payload = json.dumps( [
{
"operation": "update",
"restrictions": {
"user": [
{ "type": "known",
"username": "<string>",
"userKey": "<string>",
"accountId": "<string>"
}],
"group": [
{
"type": "<string>",
"name": "<string>",
}]
}
}
] )
r = requests.put( url, verify=False, data=payload, headers=headers, auth=(username, passwd) )
Take a look at https://developer.atlassian.com/cloud/confluence/rest/#api-content-id-restriction-put for reference...try to do a get permission on the page first to understand what kinda operation there is...do not use administer as the operation...that's for cloud
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This one doesn't work either.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes i most definitely can. Just verified it on 7.4.1 Confluence Server.
Take note that this is a page restriction update, not space permission restriction.
Again to reiterate, make sure you know the group name if you are adding the group, if it's an individual, make sure you get the userKey, username, displayName. If you don't know, simply do a get on a page that has that user/group on the page restrictions
url = BASE_URL + pageId + PERM_URL
headers = { "X-Atlassian-Token": "nocheck" }
payload = {
"expand" : "update.restrictions.user,read.restrictions.group,read.restrictions.user,update.restrictions.group"
}
r = requests.get(url, verify=False, headers=headers, params=payload, auth=(username, passwd))
#Check for successful call
if r.status_code == 200:
print r.text
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much.
Do you know how to lock the page by groovy or REST API?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It looks like that is method of update read permission, is it possible to lock one page edit permission but keep all read permission as before?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.