How to import Crowd groups in Artifactory using the REST API?

How to import Crowd groups in Artifactory using the REST API?

AuthorFullName__c
Muhammed Kashif
articleNumber
000004882
ft:sourceType
Salesforce
FirstPublishedDate
2020-10-22T16:07:58Z
lastModifiedDate
2020-10-22
VersionNumber
5

There are occasions in which we need to import Crowd groups into the Artifactory using the REST API. We can follow the Create/Replace Group REST API to perform the Crowd groups import. Below are the steps that need to be followed,
1. Created users in Crowd as "test1", "test2", "test3" and added to the "testgroup" in the crowd,
User-added image
2. Connect Crowd with Artifactory and use the below Create group REST API with "realm" as "crowd",
User-added image
Make sure the group name is the same on both the JSON passed as well as in the REST API call.
3. cURL command can be used to import the Crowd group and it should be as below,

$ cat group.json
{
  "name": "testgroup",
  "autojoin": "false",
  "realm": "crowd"
}
$ curl -uadmin:password -XPUT http://localhost:8081/artifactory/api/security/groups/testgroup -H "Content-Type: application/json" -d @group.json
The "testgroup" will be imported successfully and once any user assigned to this "testuser" in the Crowd logs in will be automatically be assigned to the "testgroup".
User-added image
No Crowd users ever logged in to Artifactory and the "testgroup" is empty,
User-added image
When the user "test1" logs-in the Artifactory, the user "test1" is automatically assigned to the "testgroup" as it was assigned in the Crowd,
User-added image