Using API to create user

danielo

Cadet
Joined
Apr 14, 2023
Messages
1
Hi!

I would like to create a user using API.
I am almost there, but I would really like to specify the user's primary group. Here is my command:

curl -X 'POST' \
'http://10.50.152.221/api/v2.0/user' \
-H "Authorization: Bearer $key" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"username": "testuser",
"full_name": "Test User",
"password": "mypassword",
"group_create": false,
"group": 1010,
"uid": 1011,
"home": "/nonexistent",
"shell": "/usr/sbin/nologin"
}'

With the above command I get "Group 1010 not found" but there is infact a group called "testgroup" with GID 1010.

Now if I write for instance "group": 34, then it creates the user with primary group 666 (webdav) and auxillary group 545 (builtin_users). But I cannot see GID 34 anywhere after creation.
What is going on and how can I specify the primary group GID for the user correctly?

(group expects integer btw)

It would be nice to be able to retrieve this info somehow, because checking the inbuilt docs gives me no idea about what to do, but surely there must be someway to retreive the right syntax etc.

Thanks in advance!
Danielo
 
Top