Creating users through the API, I can't get it to accept the "bsdusr_group" argument

Status
Not open for further replies.

ROT Tom

Dabbler
Joined
Sep 28, 2017
Messages
15
Here's the shell line I'm using to try to use the API to create a user account:

Code:
curl -X POST -u root:[password was here] -H 'Content-Type: application/json' -d '{  "bsdusr_password": "TestPassword",  "bsdusr_creategroup": false,  "bsdusr_username": "testUser",  "bsdusr_full_name": "Testy McUserface",  "bsdusr_uid": 1033, "bsdusr_group": 1006}' http://192.168.10.222/api/v1.0/account/users/


But I get the response:
Code:
{"bsdusr_group": ["Select a valid choice. That choice is not one of the available choices."]}

But the group 1006 exists... that's what almost all our users are in. If I use the API to retrieve user infomation, it returns the group exactly the way I'm submitting it:
Code:
, "bsdusr_group": 1006,


I tried some other groups, including wheel (0), but I got the same response.

Also, incidentally, the parameter "bsdusr_uid" is required? Whether you go through the FreeNAS web GUI, or use adduser in the shell on a regular *NIX, that's optional... if you leave it blank in adduser, it autofills the next available number, and in the FreeNAS API, the form for adding a user comes up with the next available number automatically filled in. It looks like every time I want to use the API to add a user, I first need to use the API to retrieve a list of all users and then parse the list to find out the last user number and add 1? Isn't not knowing which ID's are available going to be the standard usage case when creating a user through the API? How often do admins actually want to designate specific numbers for new users?

/rant

Anyway, I can handle finding the user ID programmatically, I just need help with specifying a valid group ID.

Thanks,

Tom.
 

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,194
I don't think there's much API experience on the forums, so you might want to file a bug report, at least to clear up the documentation.
 

ROT Tom

Dabbler
Joined
Sep 28, 2017
Messages
15
OK, thanks... I was hoping someone else would just point out a stupid mistake I was making, but I'll do a bug report.
 
Status
Not open for further replies.
Top