Missed Team ’24? Catch up on announcements here.

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

How to add space permissions using Confluence API?

PeterL March 19, 2015

I want to add space permissions for a user/group using the Remote API. In the docs i found the function.

boolean addPermissionsToSpace(String token, Vector permissions, String remoteEntityName, String spaceKey) 
- Give the entity named remoteEntityName (either a group or a user) the permissions permissions on the space with the key spaceKey.

My problem is, i don't know what the JSON should look like for the function. The problem is, i don't know how to map the "Vector" Object to JSON.

I tried the following wihtout success.

1. [["EDITSPACE", "VIEWSPACE"], "confluence-users","SPMJ"] 
2. [[{"EDITSPACE", "VIEWSPACE"}], "confluence-users","SPMJ"]

 

Could someone please post an example?


I do a POST on following URL: 

https://{confluenceURL}/rpc/json-rpc/confluenceservice-v2/addPermissionsToSpace

3 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 19, 2015

Actually, you can use the old remote APIs with simple JSON, that's why it's referred to as a JSON-RPC API.

This worked for me when I pasted it into the javascript console.  Don't forget you have to be logged in as administrator.

var requestArray = [];
var permissionsArray = [];
permissionsArray.push("VIEWSPACE");
permissionsArray.push("EDITSPACE");
requestArray.push(permissionsArray);
requestArray.push("confluence-users");
requestArray.push("SPMJ");
jQuery.ajax({dataType: 'json',
            contentType: 'application/json',
            type: 'POST',
            url: contextPath + '/rpc/json-rpc/confluenceservice-v2/addPermissionsToSpace',
            data: JSON.stringify(requestArray),
            success: function( data ) {
              console.log(data);
            }
});
PeterL March 19, 2015

Thanks! Worked for me too.

Emanuel Konringer August 28, 2019

How are the other parameters called (e.g. DELETE OWN, DELETE PAGE, etc..)

 

EDIT:

So far I've found out the following:

"VIEWSPACE",
"EDITSPACE",
"REMOVEPAGE",
"EDITBLOG",
"REMOVEBLOG",
"COMMENT",
"REMOVECOMMENT",
"CREATEATTACHMENT",
"REMOVEATTACHMENT",
"REMOVEMAIL",
"REMOVEOWNCONTENT",
"EXPORTSPACE",
"SETPAGEPERMISSIONS",
"REMOVEPAGE"

Like # people like this
1 vote
Mirko Skramusky
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 19, 2015

Hi!

This remote api is based on SOAP (WebService) protocol, you cannot use simple JSON.

https://developer.atlassian.com/confdev/confluence-rest-api/confluence-xml-rpc-and-soap-apis

 

Maybe it's better to use REST?

https://developer.atlassian.com/confdev/confluence-rest-api

 

Regards, Mirko

 

"Peter Lustig" laugh

0 votes
PeterL March 19, 2015

Sorry, i mean the REST-API, see https://developer.atlassian.com/confdev/confluence-rest-api/confluence-json-rpc-apis.

"Send POST requests to the Confluence API exposed via JSON-RPC at /rpc/json-rpc/confluenceservice-v2."

My only problem is, i don't know how to map "Vector" to JSON.

Can someone post an example, what the JSON must look like.

Mirko Skramusky
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 19, 2015

Yes, you are right! That was my mistake. Looks like Stephen posted the right answer.

TAGS
AUG Leaders

Atlassian Community Events