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.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Remove page restrictions via REST-API

Dirk Eyfrig December 6, 2024

 

Hi,

I'm trying to remove page read restrictions with the below REST call.

function removePageRestriction() {
  const bodyData = `[{
"content": {
  "expanded": true,
  "idProperties": {}
  },
"operation": "read",
"restrictions": {
  "user": {},
  "group": {}
  }
} ]`;
fetch('https://MYIP/rest/api/content/2367857478/restriction', {
  method: 'PUT',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json'
    },
  body: bodyData
  })
.then(response => { alert( `Response: ${response.status} ${response.statusText}` );
  return response.text(); })
.then(text => alert(text)) .catch(err => alert(err));

But upon execution, I receive an error 405.

Note: the code is taken from https://developer.atlassian.com/server/confluence/rest/v920/api-group-content-restrictions/#api-rest-api-content-id-restriction-put

I have no issues reading the restrictions of that page by using https://developer.atlassian.com/server/confluence/rest/v920/api-group-content-restrictions/#api-rest-api-content-id-restriction-byoperation-get

Has anyone successfully removed page restrictions from confluence pages via REST API?

Or - even better - is there any Confiforms IFTTT method to REMOVE all restrictions from a page (Setting restrictions is easy, but removing?)?

Regards,

Dirk

2 answers

1 accepted

0 votes
Answer accepted
Dirk Eyfrig December 10, 2024

The solution can be found here:
https://community.developer.atlassian.com/t/remove-page-restrictions-via-rest-api/86971/9?u=dirkeyfrig

On pre 8.8.0 installations, the path is /rest/experimental/content/{contentId}/restriction,
from 8.8.0 onwards it should be /rest/api/content/{contentId}/restriction

0 votes
Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
December 6, 2024 edited

Hi @Dirk Eyfrig 

 

Does this work ?

/rest/api/content/{contentId}/restriction/byOperation/read

 

 

{
  "restrictions": {
    "user": [],
    "group": []
  }
}
Dirk Eyfrig December 8, 2024

Hi @Florian Bonniec 

unfortunately not, I receive the same error 405. I've also tried /experimental/ instead of /api/, as proposed by someone else, but that just gives me an error 404.

I'm giving up on this, possibly it's a specific issue of our setup...

 

 

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Upcoming Confluence Events