Add user to group - Crowd Rest API

Parvaneh Zand
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.
July 28, 2020

Hi,

I want to add a user as a direct member to a group via rest API.

I'm using crowd admin for authorization (basic mode). But the result is: Application failed to authenticate! "401".

I can log in to crowd using crowd admin username and password. I don't know how to fix this status.

Any suggestion?

 

curl --location --request POST 'https://localhost/crowd/rest/usermanagement/1/group/user/direct?groupname=samplegroup' \--header 'Authorization: Basic username&password' \--header 'Content-Type: application/json'\ --data-raw '{"name""sampleuser"}'

 

4 answers

0 votes
BIF01 February 16, 2023

Same error

401 Unauthorized

Application failed to authenticate

using Crowd REST API https://docs.atlassian.com/atlassian-crowd/5.1.0/REST/#usermanagement/1/group-addUserAsDirectGroupMember.
Credentials are correct since other Crowd REST APIs work as expected.

Any advice?
Thanks in advance.
Cheers.

BIF01 February 16, 2023

Gotcha!

Please note that the usermanagement resource expects the callers to authenticate using the application credentials (i.e. the application name and password configured in Crowd). Calls to this APIs are restricted by IP as configured.

Other resources expect the callers to authenticate using the user credentials. 

0 votes
Penn December 3, 2021

I wrote a wrapper in Rust as well as leveraged ScriptRunner and HttpURLConnection to do REST API calls with our Crowd instance. In the base formatting for my json and URL looked similar to below:

URL:

http://crowdBaseUrl/crowd/rest/usermanagement/latest/user/group/direct?username="user unique ID"

JSON:

"{"name": "NAME OF GROUP", "description": "LEFT BLANK", "type": "GROUP", "active": "true"}"

BIF01 February 16, 2023

URL:

http://crowdBaseUrl/crowd/rest/usermanagement/latest/user/group/direct?username="user unique ID"

JSON:

"{"name": "NAME OF GROUP", "description": "LEFT BLANK", "type": "GROUP", "active": "true"}"

So, Crowd REST API https://docs.atlassian.com/atlassian-crowd/5.1.0/REST/#usermanagement/1/user-addUserToGroup is working for you?

Thanks in advance.
Cheers.

Penn February 17, 2023

Yeap! Been working since we deployed the applet to do the group assignments! Is yours not? Have you manually executed the REST API call in the browser to validate that you're hitting the API correctly?

0 votes
Penn December 3, 2021

The username password you're using is the application username password correct? These are defined as applications in crowd, not as users in crowd.

Parvaneh Zand
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.
April 5, 2023

Hi @Penn , thanks for your answer. I am using Crowd Admin User (internal user!)

What is Application username exactly?

Penn April 5, 2023

@Parvaneh Zand when you look at your crowd installation, in the web interface you have "Applications" at the top. Within Applications you define each application and the access controls for the application. The "Name" in each application as well as the "Password" for that application are what I'm referring to. I believe these are the access control values you need to be supplying.

0 votes
keremh December 7, 2020

I have the same problem, any solution found?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events