Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×I am trying to set a Confluence page restriction using Python and the Confluence REST API. I am not having any luck on Confluence 6.0.4
My code snippet is
create={ "type":"page",
"title":"1.1.23",
# "restrictions":[{"operation": "read","type":"group", "name": "cam-1.3"}],
"read":{"operation":"read","restrictions":{"group":{"results":[{"type":"group","name":"cam-1.3"}]}}},
"ancestors":[{"id":"25994717"}],
"space":{"key":"~danciarlette-admin"},
"body":{"storage":{"value":'<p><ac:structured-macro ac:name="attachments" ac:schema-version="1" ac:macro-id="ec23f1c2-0df6-437d-9ad0-d1e0b1248811"><ac:parameter ac:name="upload">true</ac:parameter></ac:structured-macro></p>',"representation":"storage"}}
}
r=requests.post(url, data=json.dumps(create),auth=('admin', 'admin'), headers=({'Content-Type':'application/json'}))
It creates the page but the restrictions are not there.
Any help or pointing me to a resource would be great.
Thanks.
Hi, Daniel.
The restrictions cannot be set while creating a page through the REST API. And currently, there's no official REST API call that will allow you to set restrictions in Confluence pages/spaces.
However, I was able to find two other topics in our community with alternatives to set it:
In short, you'll have to make at least two calls to get your page created with the proper restrictions.
I hope it helps, Daniel! :)
- Mallmann
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.