Skip to main content
psilvarochagome
Gold ⭐️
Nov 16, 2021 1:03 PM UTC
Solved

Add Users to Ranger via RESTAPI

Hello.

I'm trying to add users to Ranger via RESTAPI, but I could only add one singular user at a time.

This is the command I'm using with a json file

 

curl -u admin:$PASSWORD -i -X POST -H "Accept: application/json" -H "Content-Type: application/json" https://$RANGER_URL:6182/service/xusers/secure/users -d @users_RESTAPI.json -vvv

 

And the json file as the following

{ "name":"user_1",

  "firstName":"",

  "lastName": "",

  "loginId": "user_1",

  "emailAddress" : "",

  "description" : "",

  "password" : "pass123",

  "groupIdList":[3],

  "status":1,

  "isVisible":1,

  "userRoleList": [ "ROLE_USER" ],

  "userSource": 0

},

{ "name":"user_2",

  "firstName":"",

  "lastName": "",

  "loginId": "user_1",

  "emailAddress" : "",

  "description" : "",

  "password" : "pass123",

  "groupIdList":[3],

  "status":1,

  "isVisible":1,

  "userRoleList": [ "ROLE_USER" ],

  "userSource": 0

}

 

Only the first user is added, the following entries are ignored.

Do the users need to be added one by one via RESTAPI?

Thanks

pbhagade
pbhagadeAnswer
Gold ⭐️
Nov 29, 2021 9:52 AM UTC

Yes, you need to add one user at a time, You cannot add multiple users in a single JSON file.

1 reply

pbhagade
Gold ⭐️
pbhagadeAnswer
Gold ⭐️
Nov 29, 2021 9:52 AM UTC

Yes, you need to add one user at a time, You cannot add multiple users in a single JSON file.

Translate