Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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 Champion
December 6, 2024

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
AUG Leaders

Atlassian Community Events