Forums

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

Couldn't update page restriction via REST API (500 error)

vkochugova
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 9, 2022

Hi!

I've tried to add restriction for the page, but I've got 500 status code.

My request was:

POST /wiki/rest/api/content/{id}/restriction

Body:

{
"operation": "update",
"restrictions": {
"group": [
{
"type": "group",
"name": "<group name>"
}
]
}
}

 

Response:

{
"statusCode": 500,
"message": "java.lang.NullPointerException: null"
}


Returned message isn't informative and solution isn't clear for me :(

Thanks!

1 answer

0 votes
Alex Koxaras -Relational-
Community Champion
November 9, 2022

Hi @vkochugova and welcome to the community!

Try PUT instead of POST

Update restrictions

PUT /wiki/rest/api/content/{id}/restriction

Updates restrictions for a piece of content. This removes the existing restrictions and replaces them with the restrictions in the request.

Permissions required: Permission to edit the content.

Connect app scope requiredWRITE

OAuth 2.0 scopes required:
ClassicRECOMMENDED:write:confluence-content
vkochugova
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 9, 2022

Hi @Alex Koxaras -Relational- !

Of course I've tried!
Also I've tried different groups and I didn't get anything


if it will be useful, the GET request works fine, that is the path and the Auth creds are correct. Also it's possible to add restrictions via Web UI

Thanks!


UPD SOLVED:

  1. It works if set params to the URL path (not in the request body, as the documentation says):
    PUT /wiki/rest/api/content/{id}/restriction/byOperation/update/group/{group_name}
  2. For me it works only with PUT method (although there is a valid example with POST in the documentation)

  3. And before add restrictions for the group, you need to add restriction for current user
    PUT /wiki/rest/api/content/{id}/restriction/byOperation/update/user?accountId={current user ID}

 


Hopefully someone will fix this in the documentation.

Thanks!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events