Project

General

Profile

Bug #26067

Use Object ID for group in API

Added by Tom Ingling about 1 year ago. Updated about 1 year ago.

Status:
Resolved
Priority:
No priority
Assignee:
William Grzybowski
Category:
Middleware
Target version:
Seen in:
Severity:
New
Reason for Closing:
Reason for Blocked:
Needs QA:
No
Needs Doc:
Yes
Needs Merging:
Yes
Needs Automation:
No
Support Suite Ticket:
n/a
Hardware Configuration:

iXsystems FreeNAS Certified Server, Dual CPU, 24 bays
Build FreeNAS-11.0-U3 (c5dcf4416)
Platform Intel(R) Xeon(R) CPU E5-2609 v2 @ 2.50GHz
Memory 65464MB
2 bonded 10 GiB fiber

ChangeLog Required:
No

Description

Here's the shell line I'm using to try to use the API to create a user account:

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:

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

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:

, "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? I expect that not knowing which ID's are available is the standard usage case when creating a user through the API. How often do admins actually want to designate specific numbers for new users?

Anyway, I can handle finding a user ID as mentioned above, I just need help with specifying a valid group ID.

Thanks,

Tom.

Associated revisions

Revision f4722456 (diff)
Added by William Grzybowski about 1 year ago

fix(api): return group id in users GET

Ticket: #26067

History

#1 Updated by Warren Block about 1 year ago

The error code should return a list of valid choices, or at least describe the format. Is it a number? A string?

#2 Updated by Dru Lavigne about 1 year ago

  • Assignee changed from Release Council to William Grzybowski

#3 Updated by William Grzybowski about 1 year ago

  • Status changed from Unscreened to Screened
  • Target version set to 11.1

#4 Updated by William Grzybowski about 1 year ago

  • Status changed from Screened to 15

bsdusr_group as the API doc says, its the ID of the group in group list, not the GID.

Can you try that and let us know?

#5 Updated by Tom Ingling about 1 year ago

Sorry, I'm new at this. I've been Googling things like "BSD Group ID", "BSD group list," etc, but I can't figure out what the "ID of the group in group list" is or where I find it, can you be more specific?

#6 Updated by Tom Ingling about 1 year ago

I tried just opening /etc/groups , which doesn't show any ID's except GID, but I thought maybe the "ID of the group" would just be it's position in linear order in the list, so I tried that. This time is did successfully create the user without error, but the group the user ended up in is off by 2 positions from its order in the list. So I did find a way to make the API work, but I still don't know how to find the correct identifier to specify the group.

Thanks,

Tom.

#7 Updated by William Grzybowski about 1 year ago

Make a GET to http://192.168.10.222/api/v1.0/account/groups/

`id` is what you want, not `bsdgrp_gid`.

#8 Updated by Tom Ingling about 1 year ago

Thanks, got it now.

This should be fixed though, right? That when you query accounts through the API, the value returned as "bsdusr_group" is the GID, but to submit through the same API, the value required for the identical identifier "bsdusr_group" is not the GID, but this other ID value for the group?

Is there a place I should submit this as a feature request or something? Also, making bsdusr_uid optional? This API is... not as user friendly as possible.

Thanks for the help! Got it working now,

Tom.

#9 Updated by William Grzybowski about 1 year ago

  • Status changed from 15 to Ready For Release
  • Target version changed from 11.1 to 11.1-BETA1

Tom Ingling wrote:

Thanks, got it now.

This should be fixed though, right? That when you query accounts through the API, the value returned as "bsdusr_group" is the GID, but to submit through the same API, the value required for the identical identifier "bsdusr_group" is not the GID, but this other ID value for the group?

Right, just fixed in f472245671

Is there a place I should submit this as a feature request or something? Also, making bsdusr_uid optional? This API is... not as user friendly as possible.

We will not be making improvements in 1.0 API unless its absolutely necessary.

We are working towards REST v2.0 and websocket API.

#10 Updated by Dru Lavigne about 1 year ago

  • Subject changed from Using the API to create a new user account, arguments for "bsdusr_group" are not accepted. to Use GID for group ID in API

#11 Updated by William Grzybowski about 1 year ago

  • Subject changed from Use GID for group ID in API to Use Object ID for group in API

#12 Updated by Dru Lavigne about 1 year ago

  • Status changed from Ready For Release to Resolved

#13 Updated by Joe Maloney about 1 year ago

  • Needs QA changed from Yes to No
  • QA Status deleted (Not Tested)

Also available in: Atom PDF