Allow administrators to edit a restricted page
Asked by Olivier Crozier:

Hello,

In the opposite of some other questions, it there any "automated" or "general configuration" way to allow an administrator to change the restriction on a confluence page?

Let me explain...

Due to some infrastructure change we might need to update several pages on a confluence with the help of a script. There are different solutions based on the Confluence CLI or with python.

However the page edit fails if the page is restricted.

An administrator can view a restricted page (as long as he knows the url) and even change the restriction on this page in order to allow himself to edit its content. He can also remove this permission then after.

Conclusion: An administrator can change the page permission on a restricted page via the GUI. Is there any equivalent solution with script? Alternativaly is there any general configuration that would allow an administrator to edit every page?

Thanks in advance,  
Best regards,  
Olivier


Answers:
author: Olivier Crozier
body: Eventually I found the python solution thanks to the [](https://developer.atlassian.com/display/CONFDEV/Remote+Confluence+Methods "Remote Confluence Methods")<https://developer.atlassian.com/display/CONFDEV/Remote+Confluence+Methods>.

```
pageperms = client.confluence2.getContentPermissionSet(token, page['id'], 'Edit');    tmppageperms = copy.deepcopy(pageperms)    for contentPermission in tmppageperms['contentPermissions']:        if contentPermission['userName'] == user:            break;    if ('contentPermission' not in locals() or contentPermission['userName'] != user):        tmppageperms['contentPermissions'].append({'userName': user, 'type': 'Edit'})    client.confluence2.setContentPermissions(token, page['id'], 'Edit', tmppageperms['contentPermissions']);    raw_input('Press Enter to continue...')    client.confluence2.setContentPermissions(token, page['id'], 'Edit', pageperms['contentPermissions']);
```

To be combined with the update page routine as described in this other article [](../104580/how-to-update-a-page-from-python "how-to-update-a-page-from-python")<https://answers.atlassian.com/questions/104580/how-to-update-a-page-from-python>.


author: Bob Swift (personal)
body: Using [Confluence Command Line Interface](https://bobswift.atlassian.net/wiki/display/CSOAP) and the [addPermissions](https://bobswift.atlassian.net/wiki/display/CSOAP/Documentation#Documentation-addPermissions) action:

```
confluence --action addPermissions --space Experiment --title myPage --permissions view,edit --userId automation
```

comments: author: Olivier Crozier
body: Ah yes I did not see this action. Thanks for the info.

The thing is I started with a python script and I discovered later that Confluence CLI can also update the page content (eg getSource+storePage).

I'm sure there's a solution with python but I could not find it.


author: Steve Gerstner [bridgingIT]
body: 1. You can download a xml export of your space.
2. Then edit it witth a script
3. Delete the space
4. Upload your modified export

Regards

Steve

comments: author: Olivier Crozier
body: Thanks you Steve for this other solution.

I think it's a bit tricky to delete a space so I would rather avoid this.


Tags: administration

restriction