used API to PUT users in a static group, but while the export is correct, visually it shows theres only 1 user

beeboo
Contributor

verified the API via POSTMAN and it shows 1 user (<size>1</size>
but if i VIEW the group, theres the expected value of 7.

exporting shows the information too.

not sure how this will cause issues in the future as i expect to be running this once a month.

The API, as i have tested before, is set to add users without a computer to a static computer group, but before i do it at large, i wanted to test on a small group of users to i changed it scope to a set (small) computer group instead where i find the serial, then find the username of those machines, then i add it to the smart group.

the concern here is if i do this every month, will there be issues with this?
not sure why the API is doing this, but it seems to be just an issue with displaying it - maybe its how im putting the users to the group?

here is workflow
(assume credentials are loaded/added as a variable)

VAR1 to list all users with no laptops
for each VAR1, do
VAR2 find the username
VAR3 to static group ID
VAR4 xml header
VAR5(adds user to static group)="<user_group><user_additions><user><username>$VAR2</username></user></user_additions></user_group>"

command to actually PUT info
curl -X PUT -k -u ${api_user}:${api_pass} "${jamf_url}/${VAR3}" -H "Content-Type: text/xml" -d "${VAR4}${VAR5}" -X PUT

2 REPLIES 2

dkmansion
New Contributor II

Hi beeboo,

I tested with Postman also and adding users as you mentioned shows me a size equal to the number of users that currently exist even after appends of new users.

Had one in size then added 2 users then had <size>3</size>

I used 2 blocks in the XML for the <user> info, <user></user><user></user>.

Be sure that the code you are actually running is not using <users> instead of <user_additions> as sending the <users> block will replace the entire list of users with only what is in your single PUT at runtime.

Looping a list of 10 would replace each proceeding user with the next until only #10 is in your listing.

Also note in the web interface all users in your tenant are in the list but note that the ones not assigned to your group do not have a check box set for assignment, could that be the mismatch you are seeing? ie 7:1
Donald
c9853d9845564ffaa14ce676da2f544c

beeboo
Contributor

@dkmansion

im using the user_additions

<user_group><user_additions><user><username>$username

i do the same with the computer groups except i do computer_additions unless something needs to be changed in that code

Thanks!