You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.
View groupJoin the community to find out what other Atlassian users are discussing, debating and creating.
I'm totally new to rest api and I do not know where to start. But after some googling I tried this in powershell
curl --request POST \
>> --url 'https://confluenceURI/rest/api/group/user?name={name}' \
>> --header 'Content-Type: application/json' \
>> --data '{
>> "accountId": "{---}"
>> }'
But it's giving me an error
At line:2 char:5
+ --url 'https://confluenceURI/rest/api/gr ...
+ ~
Missing expression after unary operator '--'.
At line:2 char:5
+ --url 'https://confluenceURI/rest/api/gr ...
+ ~~~
Unexpected token 'url' in expression or statement.
At line:3 char:5
+ --header 'Content-Type: application/json' \
+ ~
Missing expression after unary operator '--'.
At line:3 char:5
+ --header 'Content-Type: application/json' \
+ ~~~~~~
Unexpected token 'header' in expression or statement.
At line:4 char:5
+ --data '{
+ ~
Missing expression after unary operator '--'.
At line:4 char:5
+ --data '{
+ ~~~~
Unexpected token 'data' in expression or statement.
At line:4 char:9
+ --data '{
+ ~
The Data section is missing its statement block.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingExpressionAfterOperator
Our confluence is on server. Any help would appreciated.
Hi,
There isn't an official REST API endpoint to add users to groups unfortunately. See https://docs.atlassian.com/ConfluenceServer/rest/7.9.1/ for what is available.
With respect to curl, I'm guessing your query came from another website. It looks like the >> indentation is confusing Powershell. Try
curl --request POST \
--url 'https://confluenceURI/rest/api/group/user?name={name}' \
--header 'Content-Type: application/json' \
--data '{ \
"accountId": "{---}" \
}'
I've also added some further \ to the last two lines.
Cheers, Jimmy
Hi @JimmyVanAU
Does that means I'll be not able to add users in a group using rest; writing anything in Powershell?
For >>, when I copy paste everything it just comes by default and I can not remove it. Not sure if I'm doing anything wrong.
Just conforming what would you right the name and acountid here:
"accountId": "{---}"
user?name={name}'
and again it's giving me the same errors
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Spatel
Let me emphasize on the difference here. First of all, there's no API for adding users to group on Confluence Server. secondly, Atlassian Server Products doesn't use accountId, so the example you might be using is totally wrong.
I would suggest you look into using an SQL query, if you want to add users to a group on confluence server. A simple query to see a list of users and their matching groups below to give you an idea.
select cd.id, cd.user_name, cd.active, g.group_name, g.lower_group_name from cwd_user cd
join cwd_group g on cd.directory_id = g.directory_id;
Once you have an idea of how the structures are, then you can simply do an "insert" query to add a new user into a specific group that exist on the table cwd_group which is where the user groups are stored. Also you might want to do a directory search prior to know what kind of directory exist on your Instance.
select * from cwd_directory;
I highly recommend, you run a test environment for Confluence Server and perform such SQL queries to see the result. Then, if it's what you're looking for, you can apply that to your Production environment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot for detailed explanation, but I don't have access to backend and that's the reason I'm trying to do from PowerShell. Do you have any other suggestions, that I can try in PwoerShell?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Spatel,
There aren't many alternatives unfortunately. There's AtlassianPS (https://atlassianps.org), but that builds on the REST API. Development also looks to have stalled. May be worth asking the AtlassianPS Slack community for suggestions.
Are marketplace apps an option? Bulk User Upload Management Utility (https://marketplace.atlassian.com/apps/126/bulk-user-upload-management-utility?hosting=server&tab=overview) may be worth your while.
Otherwise it may help to step back, look at the bigger problem, consider authentication as the larger problem, and investigate SAML SSO. Many of those apps will allow you to create users (on first login, or in bulk) and keep them updated directly from your source user directory, be it Azure AD, G Suite, Okta, etc.
Cheers, Jimmy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Connect with like-minded Atlassian users at free events near you!
Find an eventConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.
Host an eventYou're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.